所有的运行命令都要遵从pytest.ini文件
[pytest]
# 参数
addopts= -vs
testpaths= ./test_cases
# 重新规定用例所在文件 类 方法名称规则
python_files= test_c*.py
python_classes=
python_functions=
# 可以通过命令pytest --markers查看
markers=
smoking: smoking test cases
high: high test cases
项目文件夹下建立run.py文件
import pytest
import os
import time
# 主运行函数,运行规则遵照pytest.ini文件
if __name__ == '__main__':
pytest.main()
time.sleep(3)
# todo:运行生成报告命令
# 将 ./allure-results 目录下的测试数据生成html测试报告到 ./fileresult 路径下。–clean 先清空测试报告目录,再生成新的测试报告。
os.system("allure generate ./result -o ./report --clean")
time.sleep(3)
#启动一个web服务,将已经生成的html测试报告在默认的浏览器中打开,地址为:http://localhost:885/
os.system("allure open -h 127.0.0.1 -p 885 ./report")