【问题标题】:Is there a way to keep files even when using --alluredir即使使用 --alluredir 也有办法保留文件
【发布时间】: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


    【解决方案1】:

    Allure 可以从多个测试结果中生成一份报告。

    但是 py.test allure 适配器在运行前会清除结果目录。

    所以你必须在不同的目录中收集结果,然后在生成报告之前将它们放在一个目录中。

    但这应该是不同的测试用例集。

    【讨论】:

    • 谢谢你,这就是我想出来的。但是我没有把它们都放在一个目录中,我只是让 allure 搜索所有 .xml 测试结果文件并将它们全部放入最终报告中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    • 2021-11-24
    • 2011-09-23
    • 2016-05-08
    相关资源
    最近更新 更多