老师,为什么suite = unittest.main()跑不出测试报告,而 suite = unittest.TestSuite()能跑出来呢? |
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()