老师,为什么suite = unittest.main()跑不出测试报告,而 suite = unittest.TestSuite()能跑出来呢? |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | if __name__ = = '__main__' : suite = unittest.TestSuite() suite.addTest(FirstCase( "test_login_email_error" )) suite.addTest(FirstCase( "test_login_name_error" )) suite.addTest(FirstCase( "test_login_password_error" )) suite.addTest(FirstCase( "test_login_code_error" )) suite.addTest(FirstCase( "test_login_success" )) file_path = os.path.join(os.getcwd() + '/report/' + 'first_case.html' ) f = open (file_path, 'wb' ) runner = HTMLTestRunner.HTMLTestRunner(stream = f,title = "This is first case" ,description = u '这是我们第一次测试报告' ,verbosity = 2 ) runner.run(suite) f.close() if __name__ = = '__main__' : suite = unittest.main() file_path = os.path.join(os.getcwd() + '/report/' + 'first_case.html' ) f = open (file_path, 'wb' ) runner = HTMLTestRunner.HTMLTestRunner(stream = f,title = "This is first case" ,description = u '这是我们第一次测试报告' ,verbosity = 2 ) runner.run(suite) f.close() |