1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
def run_case(data): ... test = CustomAirtestCase(data["root_path"], data["dev_connect"]) test.run_air(data)
def run_air(self, data): self.recording = data["recording"] self.report_host = "http://" + data["report_host"] + ":" + data["local_host_port"] threading.Thread(target=HttpServer.start, args=(), kwargs={"local_host_path": data["local_host_path"], "report_host": data["report_host"],"port": data["local_host_port"]}).start() start_time = datetime.now().strftime("%H:%M:%S") pool = Pool() pool.map(self.run_case1, data["test_case"]) ... test_modules_dev = Runner3Common.get_case_module_dev(PATH("config/case_data.json")) print("==设备=%s" % test_modules_dev) Runner3Common.set_result_summary_json({"total_time": total_time, "phone": test_modules_dev["test_dev"], "modules": test_modules_dev["test_modules"]})
def run_case1(self, data_item): _dev = data_item["dev"] Runner3Common.set_case_module_dev({"test_dev": _dev}) for i in data_item["test_module"]: get_case_data = Runner3Common.get_cases(data_item, _dev, self.root_path) for i in get_case_data: air_device = [self.dev_connect + _dev] run(root_dir=self.root_path, test_case=i, device=air_device, local_host_path=self.local_host_path,log_date=self.log_date, recording=self.recording, report_host=self.report_host, phone=data_item["phone"])
def run(root_dir, test_case, device, local_host_path, log_date, recording, report_host, phone): script = os.path.join(root_dir, test_case["module"], test_case["case"]) log_host_path = os.path.join(test_case["module"], test_case["case"].replace('.air', '')) log = os.path.join(local_host_path, log_host_path) os.makedirs(log) print(str(log) + ' 创建日志文件成功') output_file = os.path.join(log, 'log.html') args = Namespace(device=device, log=log, compress=None, recording=recording, script=script, no_image=None) st_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") s_time = datetime.now().strftime("%H:%M:%S") try: run_script(args, AirtestCase) is_success = True except: is_success = False end_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") e_time = datetime.now().strftime("%H:%M:%S") sum_time = get_case_total_time(s_time, e_time) rpt = report.LogToHtml(script, log, report_host + "/report", log_host=report_host + "/log/" + log_date + "/" + log_host_path)
rpt.report("log_template.html", output_file=output_file)
|