suite = unittest.TestSuite()
-
suite.addTest(类名("用例名"))
runner = unittest.HtmlTestRunner()
runner.run(suite) -
cases = [类名('用例名1'),类名('用例名2'),类名('用例名3'),类名('用例名4')]
suite.addTests(cases)
runner = unittest.HtmlTestRunner()
runner.run(suite) -
Test_dir = './'
discover = unittest.defaultTestLoader.discover(start_dir = test_dir, pattern =’unit_for*.py’) # 执行 前缀为unit_for的py文件
runner = unittest.HtmlTestRunner()
runner.run(discover) -
Suite.addTests(unitTest.TestLoader().loadTestsFromTestCase(类名))
runner = unittest.HtmlTestRunner()
runner.run(suite) -
Suite.addTests(unittest.TestLoader().loadTestsFromName(‘文件名.类名)) # 文件名不用加 .py
runner = unittest.HtmlTestRunner()
runner.run(suite)