【发布时间】:2016-12-06 16:32:29
【问题描述】:
所以我必须使用带有 junit xml 文件的 pytest 创建一个 Allure 报告。我从 test_config.py 文件中调用 pytest.main() 以在不同文件夹中启动不同类型的测试用例。
def start_pytest(args):
if pytest.main(["-x", "--alluredir=%s" % allure_path, "--junitxml=%s" % junit_path, test_1]):
sys.exit(1)
if args.test2 or args.all:
pytest.main(["--alluredir=%s" % allure_path, "--junitxml=%s" % junit_path, test_2])
if args.test3 or args.all:
pytest.main(["--alluredir=%s" % allure_path, "--junitxml=%s" % junit_path, test_3])
我认为我需要 --alluredir=somepath 选项来创建一个 XML 文件以供 Allure 使用。如果可能的话,我想拥有不同的 test_case.py 文件。现在的问题是,如果我在脚本中第二次或第三次使用 --alluredir,报告目录将被清除:
py.test --alluredir [path_to_report_dir]
# WARNING [path_to_report_dir] will be purged at first run
来源:https://pypi.python.org/pypi/pytest-allure-adaptor
那么,有没有办法在第一次使用 --allurdir 时删除目录并在第二次和第三次保留文件。还是我必须将所有测试用例写在一个文件中,所以我只需要调用 pytest.main() 一次。
感谢您的宝贵时间,非常感谢!
【问题讨论】:
标签: python junit pytest allure