目录
3. 使用 pytest 执行测试用例并生成 allure 中间报告(此步骤可以省略,因为在 jenkins job 中会配置执行类似的命令)
4. Jenkins 中安装Allure Jenkins Plugin
5. Jenkins 中配置 Allure Commandline
前言
使用Python结合Allure和Jenkins是一种强大的组合,可以实现自动化测试和测试报告的生成与展示。
之前用 python 写接口测试脚本一直用的是 HTMLTestRunner,后来发现 Testerhome 上有介绍 Allure,感觉 allure 展示的测试报告非常酷炫,所以试着将 allure 集成到测试中,在这里记录一下用做备忘。
在 python 中使用 allure
在 python 中使用 allure 需要使用 pytest 和 pytest-allure-adaptor,所以先使用 pip 安装它们俩。
1. 安装 pytest
pip install pytest
2. 安装 pytest-allure-adaptor
pip install pytest-allure-adaptor
3. 使用 pytest 执行测试用例并生成 allure 中间报告(此步骤可以省略,因为在 jenkins job 中会配置执行类似的命令)
- 我的脚本目录结构
- 在测试脚本根目录执行以下命令,跑 test_zutu_seacher.py 中的 case
python -m pytest cases/zutu_searcher/ --alluredir report
以上命令要在 pytest 的前面加上 python -m,因为如果不加会报如下的错误。可以参考
=========================================================================== test session starts =========================================