使用allure生成测试报告
一、下载allure文件
- 下载地址:https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.27.0/
- 下载zip包后解压,放到无中文名称的目录下
二、配置环境变量
1.复制allure文件下bin目录的路径
2.电脑搜索框输入path,点击环境变量-编辑-新建,将路径粘贴
- cmd查看where allure
4.修改pytest.ini文件中的addopts内容
[pytest]
addopts = -vs --alluredir ./temp
testpaths = ./TestSaasWork
python_files = test_*.py
python_classes = Test*
python_functions = test_*
markers =
smoke
#-alluredir ./temps/ 生成json格式的临时报告目录
#--clean-alluredir/ 每次生成json报告自动删除之前报告
5.在all.py文件下添加os.system(“allure generate ./temp -o ./report --clean”)
import os
import pytest
if __name__ == '__main__':
pytest.main(['-vs'])
os.system("allure generate ./temp -o ./report --clean")
#allure generate 命令,固定的
#./temp 临时的json格式报告的路径
#-o 输出output
#--clean 清空report文件夹下原来的报告
6.执行后会在temp文件夹下生成json格式的临时报告目录,在新增的report文件夹下生成报告
7.查看生成的allure报告