一、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、