import unittest import HTMLTestRunnerNew from tools.test_http_request import TestHttpRequest from tools.project_path import *
suite=unittest.TestSuite() loader=unittest.TestLoader() #第二种加载用例方法,因TestHttpRequest有装饰器ddt,第一种方法不适合 # suite.addTest(loader.loadTestsFromTestCase(TestHttpRequest)) suite.addTest(loader.loadTestsFromTestCase(TestHttpRequest))
#从project_path中打开文件并输出测试报告 with open(test_report_path,"wb") as file: runner=HTMLTestRunnerNew.HTMLTestRunner(stream=file, title="这是单元测试报告611", verbosity=2, description="这是单元测试报告611" ) runner.run(suite)