目录层级结构图

主执行文件(runner.py)
from concurrent.futures.process import ProcessPoolExecutor
import os
import time
import pytest
import yaml
from meet.public import *
from meet.concurrent_startup import *
devices_list = ['Your device uid', 'Your device uid']
def runnerPool():
with open('kyb_caps.yaml', 'r', encoding="utf-8")as file:
data = yaml.load(file, Loader=yaml.FullLoader)
print(data)
devices_Pool = data
with ProcessPoolExecutor(len(devices_Pool)) as pool:
pool.map(runPytest, devices_Pool)
def runPytest(device):
print(f"cmdopt is {device}")
report = f"report-{device['deviceName']}".split(":", 1)[0]
report_dir = mkdir_dir(report)
now_time = time.strftime("%H-%M-%S", time.localtime())
print(f"pool run device is {device['deviceName']}")
pytest.main(["-s", "./TestCases/", f"--cmdopt={device}", "--alluredir", f"./{report_dir}/{now_time}/xml"])
time.sleep(1)
os.system(f"allure generate ./{report_dir}/{now_time}/xml -o ./{report_dir}/{now_time}/html")
if __name__ == '__main__':
"""
获取服务的端口
并发启动appium的服务
多设备启动执行用例
release端口
"""
ports = []
appium_start_sync()
runnerPool()
for i in range(len(devices_list)):
port_num = 4723 + 2 * i
ports.append(port_num)
print(ports)
for t in ports:
release_port(t)
公有函数(public.py)
import time
def mkdir(path):
"""创建目录函数"""
import os
path = path.strip()
path = path.rstrip("\\")
is_exists = os.path.exists(path)