随笔:用HtmlTestRunner生成报告
import unittest
from HtmlTestRunner import HTMLTestRunner
dir = r''
discover = unittest.defaultTestLoader.discover(dir, pattern="test.py")
if __name__ == '__main__':
'''
runner = unittest.TextTestRunner()
runner.run(discover)
'''
file = open('test测试报告1.html','wb')
runner = HTMLTestRunner(stream=file,title='test测试报告',description='test详细测试报告')
runner.run(discover)
file.close()
当然python3用HtmlTestRunner需要下载和进行修改,下面链接有很详细的描述,部分行对应的可能不是很准确,但是都在差不多位置,找一下就好
https://blog.csdn.net/lucky_han/article/details/103582065
目前通过pip下载的HTMLTestRunner使用经常报错,问题在哪还不是很清楚,哪位大神知道可以指导一下就好了,哈哈