Pytest–生成测试报告

一、Pytest-html插件生成测试报告

1.在pytest.ini配置文件

#即在当前目录下生成report.html测试报告文件
[pytest]
addopts= --html ./report.html

testpaths=./test_01.py
..........

..........

测试报告示例:

Pytest--生成测试报告

二、allure-pytest插件生成allure测试报告

1、下载,解压,配置path路径
地址:https://github.com/allure-framework/allure2/releases

2、在pytest.ini文件中加入命令,生成json格式的临时报告
命令: --alluredir=./temp (#在当前目录下的temp文件夹存放json文件)

3、生成allure测试报告


os.system('allure generate ./temp -o ./report')


if __name__ == '__main__':

    pytest.main(['-vs','test_login.py','--alluredir','./allure-results'])

    os.system('allure generate ./allure-results  -o ./reports ')

注释:
allure generate:固定格式命令
./temp :临时的json格式报告的路径
-o : 输出参数(output)
./report:生成的allure报告的路径
--clean: 清空./report路径原来的报告

报告示例:

Pytest--生成测试报告

Original: https://blog.csdn.net/weixin_45981384/article/details/118630252
Author: 爆肝拳专业户
Title: Pytest–生成测试报告

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/775623/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球