前置
服务器上安装了nose、allure和pytest用例;
使用方法
先用pytest和allure生成测试报告,而后使用allure open -h 127.0.0.1 -p 8083 ./report/将生成的html文件通过浏览器进行查看,report即为allure生成的报告所在的目录,而后即可通过"http://服务器ip:8083"来访问这个allure报告了;
如下是用过的一个用于自动运行用例并打开allure报告服务的shell脚本:
#! /bin/bash
port=8083
PID=`ps -ef | grep $port | grep -v grep | awk '{print $2}'`
if [ -n "$PID" ];then
echo "`date +%F%H%M%S` testReport service $PID is running, stop it"
kill -9 $PID
fi
cd /usr/games/test/pytest/saasapitest
echo "`date +%F%H%M%S` start switch to environment $1"
echo "useEnv=$1" > config.properties
sleep 2
echo "`date +%F%H%M%S` start running test"
/usr/local/python3/bin/pytest --alluredir report/xml
echo "`date +%F%H%M%S` start generate allure repot"
allure generate report/xml -o report/html --clean
echo "`date +%F%H%M%S` start to startup report service,port:$port"
nohup allure open -h 10.1.254.63 -p $port report/html
本文介绍了一个方法,通过在服务器上安装nose、allure和pytest,先运行测试生成Allure报告,然后利用服务器IP和端口,将报告转化为可远程访问的网页。具体步骤包括使用pytest和allure生成报告,以及通过特定脚本启动服务,使得可以通过"http://服务器ip:8083"查看Allure报告。
2608

被折叠的 条评论
为什么被折叠?



