python中的allure报告使用
安装
windows:pip install allure-pytest -i https://pypi.douban.com/simple/
mac:python3 -m pip install allure-pytest -i https://pypi.douban.com/simple/
然后在pytest.ini中设置
addopts = -sv --alluredir ./report/data --clean-alluredir
(备注:–alluredir ./report/data 生成allure格式的测试结果数据,存储在./report/data目录下)
(–clean-alluredir 每次执行生成都清除之前的数据)
执行之后我们会在目录看到测试结果数据,但是这个数据都是一些json文件,读起来不容易,我们需要采用更多的手段让测试结果可视化处理
allure-pytest 会收集测试结果数据 ,报告结果放在html中
借助allure命令行工具实现
1、 安装jdk jdk安装
2、下载allure 2.11 ,解压缩,配置环境变量
3,在run.py中加入:os.system(‘allure generate ./report/data -o ./report/html --clean’)
(备注:该命令是使用python执行生成测试报告的命令)
(备注:./report/data 收集结果目录)
(备注:-o ./report/html 生成html报告目录)
(–clean 清理原来的测试报告)
在具体的测试用例中使用:
@allure.feature('测试xxx')
@allure.story('xxx接口')
class TestAA:
@allure.title('测试用例标题描述')
def test_aaa(self):
报告中新增 分层关系
特性:@allure.feature(‘’)
描述:@allure.story(‘’)
用例名称:@allure.title(‘’)