testInterface.id = str(id[0][0]) # 18 新增角色 if caseName == "新增角色": param = dict(eval(param)) Mysql_PO.cur.execute( 'select id from sys_role where roleName="%s" and status=1' % (param['roleName'])) roleId = Mysql_PO.cur.fetchall() Xls_PO.setCaseParam( excelNo, "roleId=" + str(roleId[0][0]) + ",roleName=" + param['roleName'], '', str(d_jsonres), '', '') testInterface.roleId = str(roleId[0][0]) if __name__ == '__main__': suite = unittest.defaultTestLoader.discover('.', pattern='testInterface.py', top_level_dir=None) runner = bf(suite) reportFile = '../report/saas接口测试报告_' + str(Time_PO.getDatetime()) + '.html' runner.report(filename=reportFile, description=localReadConfig.get_system("projectName")) # if platform.system() == 'Darwin': # os.system("open " + reportFile) # os.system("open ../config/" + localReadConfig.get_excel("interfaceFile")) if platform.system() == 'Windows': # os.system("start " + reportFile) os.system("start ..\\config\\" + localReadConfig.get_excel("interfaceFile"))
self.varReportFolder = varReportFolder self.varReport = varReport self.varTitle = varTitle self.varDesc = varDesc File_PO.newFolder(os.getcwd() + "/" + varReportFolder) def runner(self): # 批量执行文件 discover = unittest.defaultTestLoader.discover(self.varFolder, pattern=self.varPattern) # 报告存放的文件夹 report_path = self.varReportFolder + self.varReport # 生成测试报告 with open(report_path, 'wb') as f: runner = HTMLTestRunner(stream=f, verbosity=2, title=self.varTitle, description=self.varDesc) runner.run(discover) f.close() if __name__ == '__main__': # 执行当前目录下所有test开头的脚本,将结果保存到report目录下。(如果目录不存在,则自动创建) HtmlTestRunner_PO = HtmlTestRunnerPO( "./", "test*.py", "." + "/HtmlTestRunnerPO" + "/", "report_" + Time_PO.getDatetime() + ".html", "功能测试报告 - Func123", "副标题用例执行详细信息") HtmlTestRunner_PO.runner()