下载HTMLTestRunner:https://github.com/SeldomQA/HTMLTestRunner
python3环境下需要对HTMLTestRunner修改如下内容:
#第94行
import StringIO
修改为:
import io
#第539行
self.outputBuffer = StringIO.StringIO()
修改为:
self.outputBuffer = io.StringIO()
#第631行
print >>sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)
修改为:
print (sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime))
#第642行
if not rmap.has_key(cls):
修改为:
if not cls in rmap:
#第766行
uo = o.decode('latin-1')
修改为:
uo = o
#第772行
修改为:
ue = e
我遇到的问题,代码无错,运行程序无措,但是没有生成HTMLTestRunner报告:
网上搜了一圈,此种辛苦略去。。。终于找到原因:
我写的是unittest测试脚本,所以pycharm 在运行测试用例的时候 默认是在unittest 框架下运行的,所以不能生成测试报告
如何判断是否是用unitest框架运行的呢?