这是我的代码。它创建了文件“ smokeTest.html”,但是当我打开该文件以查看报告时,它没有任何报告。请查看代码,并向我建议更好的方法。
import unittest
import tests.test_home
import tests.test_login
import os
import HtmlTestRunner
direct = os.getcwd()
class MyTestSuite(unittest.TestCase):
def test_Issue(self):
smoke_test = unittest.TestSuite()
smoke_test.addTests([
unittest.defaultTestLoader.loadTestsFromTestCase(tests.test_login.TestLogin),
unittest.defaultTestLoader.loadTestsFromTestCase(tests.test_home.TestHome),
])
outfile = open(direct + "\SmokeTest.html", "w")
runner1 = HtmlTestRunner.HTMLTestRunner(
stream=outfile,
report_title='Test Report',
descriptions='Smoke Tests', output="example_suite"
)
runner1.run(smoke_test)
if __name__ == '__main__':
unittest.main()