Allure框架是一种灵活的轻量级多语言测试报告工具,它不仅能够以简洁的web报告形式显示已测试的内容,而且允许参与开发过程的每个人从测试的日常执行中提取最大限度的有用信息。
#安装pytest框架 pip install pytest #pytest基本报告,用于生成pytest-html报告 pip install pytest-html pip install allure-pytest pip install pytest-allure-adaptor
下载Allure命令行工具:
到girhub上下载Allure2 ,地址:https://github.com/allure-framework/allure2/releases
下载完成后,解压放到C盘目录,并配置好环境变量
如:C:\allure-2.13.6\bin 添加到Path中
在DOS中输入:
allure --version 可查看对应的版本号。
设置pytest.ini
pytest.ini的介绍可参考:https://www.cnblogs.com/yoyoketang/p/9550648.html
[pytest] addopts = -s --html=./report/html/Test_Report.html --alluredir ./report/result python_files = test_*.py python_classes = Test* python_functions = test_*
pytest 执行后会有在 ./report/result目录下生成一堆xml的报告文件,当不是我们最终想要的美观报告。
在终端中输入: allure generate report/result -o ./report/allure_html/ --clean 然后再输入,打开美观报告: allure open allure_html/
原文:https://www.cnblogs.com/yu2000/p/13864635.html