HTMLTestRunner不工作

2024-04-19 21:40:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用Selenium+Python,在研究了一个生成报告的好方法之后,我遇到了“HTMLTestRunner”,问题是我在互联网上找到了很多例子,它们都是一样的,但是当我试图让它在我的代码中工作时(主要是按play),我看不到生成的报告我没有出错,你能帮我一下吗? 这是我使用的代码:

class TestPruebaTest(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.verificationErrors = []

    def testName(self): #Some logic on the code passing driver to another class and return
        driverUtilizoPrueba = self.driver
        manejadorLogicaBMI = logicaBMI.logicaBMI(driverUtilizoPrueba,url)
        manejadorLogicaBMI.logicaPrograma()

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)


if __name__ == "__main__":
    suite = unittest.TestSuite()

    suite.addTest(unittest.makeSuite(TestPruebaTest))

    dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S')

    buf = file("TestReport" + "_" + dateTimeStamp + ".html", "wb")

    runner = HTMLTestRunner.HTMLTestRunner(

             stream=buf,

             title='Test the Report',

             description='Result of tests'

             )

    runner.run(suite)

Tags: the代码selfdef报告driverunittestclass