先简单说一下allure安装方法
1、下载allure文件
2、解压到非中文目录
3、把bin路径配置到环境变量
4、安装allure报告:pip install allure-pytest
5、验证:allure --version
生成allure报告
修改一下执行命令即可
原来是
# coding: utf-8
import os
if __name__ == '__main__':
os.system("hrun testsuites/tags_suits.yml --html=reports/report.html")
生成allure需要两步,先生成json数据文件,然后生成allure测试报告
# coding: utf-8
import os
import time
if __name__ == '__main__':
# 生成临时文件
os.system("hrun testsuites/tags_suits.yml --alluredir=reports/temps --clean-alluredir")
# 生成文件需要时间,等待3秒
time.sleep(3)
# 生成allure报告
os.system("allure generate reports/temps -o reports/allure-report --clean")
生成的json文件会越来越多,所以我们加了clean,运行时清除之前生成的文件。在对应的文件夹下就可以看到测试报告了。
os.system("hrun testsuites/tags_suits.yml --alluredir=reports/temps --clean-alluredir")
# 生成文件需要时间,等待3秒
time.sleep(3)
# 生成allure报告
os.system("allure generate reports/temps -o reports/allure-report --clean")