pytest-parallel 多线程执行和allure生成报告,allure生成报告失败
背景:
使用多线程pytest-parallel执行测试用例,使用allure生成测试报告,发现生成报告内容为NaN
使用的pytest执行命令:
pytest.main(["TestCase/test_xx.py", "-m", "test_xx", "--tests-per-worker=4", "--alluredir=./test_result/allurereport/allure-results", "--junitxml=./test_result/allurereport/report.xml", ])
问题:
测试用例执行完成后,只有report.xml的文件更新了,allure-results文件夹下,没有生成最新的文件(没有json和txt文件)
allure generate --clean 重新收集报告,打开Index.html报告,报告内容为NaN;
问题排查:
1、开始以为allure命令错误,检查命令正确;检查文件生成的路径,正确;
2、 将多线程执行的命令去掉,重新执行,allure-results有新的文件生成
结果:
多线程执行的结果,allure收集不到执行的情况,所以allure-resutls没有新文件生成;
解决方式:
要使用多线程执行用例,和生成对应的报告,要采用其他其它测试报告,pytest-html;