一、parallel 1、安装 pip install pytest-parallel 2、操作命令 –workers (optional) *:多进程运行需要加此参数, *是进程数。默认为1。 –tests-per-worker (optional) *:多线程运行, *是每个worker运行的最大并发线程数。默认为1 使用示例: pytest test.py –workers 3:3个进程运行 pytest test.py –tests-per-worker 4:4个线程运行 pytest test.py –workers 2 –tests-per-worker 4:2个进程并行,且每个进程最多4个线程运行,即总共最多8个线程运行。 参考:https://pypi.org/project/pytest-parallel/ 3、注意点: ①需要使用 if __name__ == '__main__': ②执行时间是运行时间最长的线程的时间。
③目前存在一个bug,不能和allure报告使用,会组织xml文件生成。只能希望作者尽快修复了 4、命令 pytest.main(["-v","-m","register","--alluredir=../../OutPuts/allure-results",'--workers=1','--tests-per-worker=4']) os.system(r"allure generate --clean ../../OutPuts/allure-results -o ../../allure-report ") 5、