pytest学习pytest生成html报告

# 生成html报告

  pip install pytest-html

  pytest --html=report.html  (对现有的代码进行执行)

allure2生成html报告

pip安装pytest-allure-adaptor  或者

allure-commandline releases版本https://github.com/allure-framework/allure2/releases 下载最新版后,解压到运行pytest的目录下

 并添加至设置环境变量

切换至项目所在文件夹cmd,

执行生成报告命令:

pytest --alluredir ./report/allure_raw

或者 在执行main函数如下添加执行:

 if __name__ == '__main__':
     pytest.main(["-s","-v","--html=Outputs/reports/pytest.html",
                  "--alluredir=Outputs/allure"])   # allure文件生成的目录

执行完后,输入 tree

启动服务输入allure_raw所在的目录查看测试报告

allure serve 测试结果文件目录 

allure serve report\allure_raw

就会出现漂亮的测试报告

 

原文地址:https://www.cnblogs.com/wzhqzm/p/14234809.html