出现的问题:
在做python+selenium自动化测试的时候,期望用HTMLTest批量执行测试用例,具体控制测试用例执行的代码如下:
# 用例路径
case_path = os.path.join(os.getcwd(), 'test_case')
# 报告存放路径
report_path = os.path.join(os.getcwd(), 'report')
def all_case():
discover = unittest.defaultTestLoader.discover(case_path, pattern="*.py", top_level_dir=None)
print(discover)
return discover
if __name__ == '__main__':
# 获取当前时间,这样便于下面的使用
now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
# html报告文件路径
report_abspath = os.path.join(report_path, 'report'+now+'.html')
# print(report_abspath)
# 打开一个文件,将result写入此file中
fp = open(report_abspath, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
title='datahub-