废话少说先上代码
# -*- coding:UTF-8 -*-
__autor__ = 'zhouli'
__date__ = '2018/11/12 21:29' import unittest
import unittest_import, test_suite def create_suite():
print('开始测试')
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(unittest_import.UserTestCase)) # 加上测试用例中类的名称即可
suite.addTest(unittest.makeSuite(test_suite.UserTestCase)) # 加上测试用例中类的名称即可
return suite if __name__ == "__main__":
suite = create_suite()
file_prefix = time.strftime("%Y-%m-%d", time.localtime())
print(file_prefix)
with open("./" + file_prefix + "_result.html", "wb") as f:
runner = HTMLTestRunner.HTMLTestRunner(stream=f, title=u"zl测试", description=u"执行情况")
runner.run(suite)
值得注意的是其他模块的测试是通过addTest来完成的