HTMLTestRunner
HTMLTestRunner is an extension to the Python standard library's unittest module.
It generates easy to use HTML test reports. HTMLTestRunner is released under a
BSD style license.
参考链接:
http://tungwaiyip.info/software/
https://pypi.python.org/pypi/HTMLTestRunner
安装
- 下载HtmlTestRunner.py
mac: 放在Python/2.7/site-packages下
win:放在python目录下的lib文件夹 - 使用
__author__ = 'susie'
#coding:utf-8
import unittest from src.testcase
import TopicPageimport HTMLTestRunner
import time
def suite():
suite = unittest.TestSuite()
topic_page_tests = [
TopicPage("test01"),
TopicPage("test02")]
suite.addTests(topic_page_tests)
return suite
if __name__ == '__main__':
today = time.strftime('%Y%m%d%H%m%S', time.localtime(time.time()))
reportPath = "K:/Automation/appiumCase/justFun/report/" + today + ".html"
fp = file(reportPath, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='Python Test Report', description='This is Python Report')
runner.run(suite())
-
运行结果
报告文件夹里面生成了一份html格式的报告,在浏览器打开