前言
之前用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,因为如果不加会报如下的错误。可以参考
========================================================&#