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格式的報告,在瀏覽器打開