代码拉取完成,页面将自动刷新
from multiprocessing import Pool
import concurrent.futures
import pytest, time, os, shutil, subprocess
"""
多线程执行case (未验证)
"""
# 命令模块
def run_parallel(theme):
# pytest.main([f"--cmdopt={theme}", f"./test_case/{theme}", "--alluredir", "./allure/allure-results"])
pytest.main([f"./test_case/{theme}", "--alluredir", "./allure/allure-results"])
# 用于执行指定的case
# themes = [['test_BaiDu.py', 'test_one.py'], ['test_BaiDu.py', 'test_one.py']]
themes = [['test_BaiDu.py', 'test_one.py'], ['test_BaiDu.py', 'test_one.py']]
def run_tests_with_multiprocessing(num_processes):
"""
:param num_processes: 线程数
:return:
"""
with concurrent.futures.ProcessPoolExecutor(max_workers=num_processes) as executor:
for theme in themes:
executor.submit(subprocess.run, run_parallel(theme))
# 整合到一份报告
times = time.strftime("%m_%d_%H_%M_%S")
path = f'./allure/{times}'
os.system(f'allure generate ./allure/allure-results -o {path} --clean')
if __name__ == '__main__':
import os
"""
case失败之后或者是调试时,进程不会结束。所以新执行测试之前需要先结束进程
"""
os.system('taskkill /im msedgedriver.exe /F') # 执行case之前结束 edge驱动进程
os.system('taskkill /im chromedriver.exe /F') # 执行case之前结束 Chrome驱动进程
run_tests_with_multiprocessing()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。