Allure
1、安装地址
https://github.com/allure-framework/allure2/releases
下载后解压到pytest文件夹下:C:\Users\dxj\AppData\Local\Programs\Python\Python37\Lib\site-packages\pytest
2、配置环境变量
系统变量path配置:C:\Users\dxj\AppData\Local\Programs\Python\Python37\Lib\site-packages\pytest\allure-2.17.3\bin
配置好,cmd ——》allure 出现Usage: allure [options] [command] [command options] 代表配置好
此处爬过一个坑,cmd中运行allure,pycharm的运行台提示“allure不是内部命令”
#解决方法:重启下pycharm
3、使用报告
#执行pytest单元测试,生成 Allure 报告需要的数据存在 /temp 目录
pytest.main([‘–alluredir’, ‘./temp’])
#执行命令 allure generate ./temp -o ./report --clean ,生成测试报告
os.system(‘allure generate D:\workspace\python_pytest/temp -o D:\workspace\python_pytest/report --clean’)
这个地方注意下:生成报告的路径,用./这种方式容易报错~~~~,最好给出绝对路径,避免程序找不到文件