在软件测试结束之后,一般都要求生成测试报告,在利用python写的测试脚本中可以引入HTMLTestRunner,
HTMLTestRunner是Python标准库unittest单元测试框架中的一个扩展,比较容易生成测试报告,
下载地址:http://tungwaiyip.info/software/HTMLTestRunner.html
下载之后,将其放在Python27/Lib文件夹下即可
使用过程中遇到的问题:
第一次在使用HTMLTestRunner时,运行完脚本报错:
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe7 in position 211: ordinal not in range(128)
产生原因:弄错了python2 里边的 str 和 unicode 数据类型,然后报了编码错误
解决办法:
1、将默认编码设置为utf8,可以在
import sys
reload(sys)
sys.setdefaultencoding(‘utf8’)
2、
因为python3区分了str和unicode所以可以直接使用python3