import pytest
import os
path = os.path.dirname(__file__)
path = path + "/report/"
pytest.main(["-s","--alluredir={}".format(path),
"cases"])#运行 cases下所有测试用例
result = os.system(r"allure serve {}".format(path))
print("result={}".format(result))

本文介绍了一个使用pytest进行自动化测试的实战案例,展示了如何通过pytest框架运行指定目录下的所有测试用例,并利用allure生成测试报告的过程。代码中包含了设置测试路径、运行pytest主程序、调用allure生成报告及打印执行结果等关键步骤。
2620

被折叠的 条评论
为什么被折叠?



