人生苦短,我学python之python+selenium 生成测试报告
不废话直接撸代码
import unittest import time from common import HTMLTestRunner discover = unittest.defaultTestLoader.discover( start_dir='E:\\test_ke\\testcase', pattern="test*.py", ) print(discover) # runner = unittest.TextTestRunner() # runner.run(discover) print (discover) nowtime=time.strftime('%Y-%m-%d %H_%M_%S') print (nowtime) reportPath = 'E:\\test_ke\\report\\'+'report.html' print(reportPath) fb=open(reportPath,"wb") runner = HTMLTestRunner.HTMLTestRunner(stream=fb, verbosity=2, title=u'这是我的自动化用例', description=u'关于什么项目的测试用例') runner.run(discover)