# -*- coding: utf-8 -*- import pytest import os, sys from allure_combine import combine_allure def run(): # 获取 python运行参数 # 读取命令行传入的参数 pytest_cmd_config = [] for arg in sys.argv: if arg.startswith("-"): pytest_cmd_config.append(arg) # 2. 构建pytest参数 pytest_args = ["-v", "-s", "--capture=sys","--clean-alluredir","--alluredir=allure-results",os.path.join(os.path.dirname(__file__), "apirun/core/ApiTestRunner.py")] pytest_args.extend(pytest_cmd_config) os.system(r"allure generate -c -o allure-report") combine_allure(r"./allure-report") if __name__ == '__main__': pytest_args = ["-v", "-s", "--capture=sys", '-n=1', "./apirun/core/ApiTestRunner.py", "--clean-alluredir", "--alluredir=allure-results", # "--type=yaml", # r"--cases=./examples/examples-ds" "--type=excel", r"--cases=./examples/examples-dsw" ] pytest.main(pytest_args) # TODO 代码参考如下:生成allure测试报告 os.system(r"allure generate -c -o allure-report") # 等于你在命令行里面执行 allure # TODO 3: 代码参考如下:生成allure测试报告,双击打开直接查看 combine_allure(测试报告的路径) combine_allure(r"./allure-report")