unittest生成测试报告
使用BeautifulReport:下载地址:https://github.com/TesterlifeRaymond/BeautifulReport
解压zip包,到python的/Lib/site-packages/
实例:
import unittest import os import time from BeautifulReport import BeautifulReport case_path = os.path.join(os.path.dirname(os.getcwd()), "test_case") report_path = os.path.join(os.path.dirname(os.getcwd()), "reports") now = time.strftime('%Y-%m-%d %H-%M-%S') discover = unittest.defaultTestLoader.discover(case_path, pattern="test*.py", )
report_html = BeautifulReport(discover) result = report_html.report(filename=now + 'report.html', description="测试报告", log_path=report_path)
实例结果:
测试已全部完成, 可前往D:\05_Python\Appium\unittest\reports查询测试报告