我正在尝试使用Selenium + Python,在研究了一些关于生成报告的好方法后,我遇到了“HTMLTestRunner”,问题是我已经找了很多关于互联网和他们是一样的但是当我试图让它来处理我的代码(主要是按戏)时,我看不到生成的报告而且我没有收到任何错误,你能帮我一把吗?请? 这是我正在使用的代码:
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)
答案 0 :(得分:0)
安装 HTMLTestRunner-rv
pip install htmltestrunner-rv
import time
import unittest
from runner import HTMLTestRunner
class TestPruebaTest(unittest.TestCase):
def setUp(self):
print("setup")
def testName(self): # Some logic on the code passing driver to another class and return
print("testcase")
def tearDown(self):
print("teardown")
if __name__ == "__main__":
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPruebaTest))
dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S')
runner = HTMLTestRunner(log=True,title='Test the Report',
description='Result of tests', open_in_browser=True)
runner.run(suite)