Arthur-Wu committed this file on 2024-11-15

This commit is contained in:
ieemoo
2024-11-15 17:35:57 +08:00
parent c871e12b16
commit 298268c133
20 changed files with 595 additions and 18 deletions

View File

@ -13,15 +13,16 @@ class Engine():
self.CasesSuite = []
self.rootpath = os.path.dirname(os.path.dirname(__file__))
self.FolderPath = ReturnFolder
self.projectCasesPath = str(os.path.join(GlobalPath['YMCaseScriptsPath']).replace("\\", "/"))
self.TestSuiteName = str(os.path.join(GlobalPath[ProCfgData["ExecutionScope"]]).replace("\\", "/"))
self.ReportName = "Reports"
self.newName = "亿猫业务场景接口自动化测试报告"
def __execute(self):
'''@Author:: Arthur Wu
@Date:: 2024/5/9
:return:
'''
for dirpath, dirnames, filenames in os.walk(self.projectCasesPath):
for dirpath, dirnames, filenames in os.walk(self.TestSuiteName):
for fn in filenames:
if fn.startswith("test_"):
caseScriptPath = os.path.join(dirpath, fn).replace("\\", "/")
@ -35,7 +36,9 @@ class Engine():
+ ' --workers=2 '+'--tests-per-worker=2',
shell=True,
stdout=subprocess.PIPE).stdout.read()
folder_path = os.path.join(self.FolderPath, 'html').replace('\\', '/')
LOGGER.info("---[INFO] Allure html report generate complete !")
return folder_path
def __move_file(self):
rootpath = (os.getcwd()).replace("\\", "/")
@ -65,14 +68,24 @@ class Engine():
os.remove(file_path)
print(f"已删除: {file_path}")
def __set_overview_title(self, index_path, new_name):
title_filepath = os.path.join(index_path, "widgets", "summary.json")
with open(title_filepath, 'rb') as f:
params = json.load(f)
params['reportName'] = new_name
new_params = params
with open(title_filepath, 'w', encoding="utf-8") as f:
json.dump(new_params, f, ensure_ascii=False, indent=4)
def run_test_suite(self):
txtPath = os.path.join(self.rootpath, "YiMao/ProcessData")
self.__delete_pycache_dirs(self.rootpath)
self.__delete_txt_files(txtPath)
self.__execute()
indexh5path = self.__execute()
self.__set_overview_title(indexh5path, self.newName)
returnList = []
lastReportPath = self.__move_file()
returnList.append(lastReportPath)
# lastReportPath = self.__move_file()
# returnList.append(lastReportPath)
self.__delete_txt_files(txtPath)
self.__delete_pycache_dirs(self.rootpath)
return returnList
@ -84,8 +97,8 @@ class NotificationModule():
"Debug": "7aedbee7239870e3e653748a2889d8bf063c61efa9213c7099bd57476066dc86",
"Formal": "80b026022a28166cfc9eebaf8f6a880cc06f56a14b8803e8d67e7fb3cb05844e"
}
# self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Debug"]}'
self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Formal"]}'
self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Debug"]}'
# self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Formal"]}'
self.ReportUrl = ProCfgData["ReportsURL"]
self.ExecutionEnvironment = ProCfgData["ExecutionEnv"]