添加HTML格式的测试报告 import unittest from HTMLTestRunner import HTMLTestRunner from cims.test_api import Apitest#导入测试用例suite = unittest.TestSuite()suite.addTest(unittest.makeSuite(Apitest))fp = open( " api_test.html "
添加HTML格式的测试报告
import unittest from HTMLTestRunner import HTMLTestRunner from cims.test_api import Apitest #导入测试用例 suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Apitest)) fp = open("api_test.html","wb") runner = HTMLTestRunner(stream=fp, title="api_测试报告", description=‘用例执行情况:‘) runner.run(suite) fp.close()
使用unittest.makeSuite,添加测试类下所有用例
指定测试报告名称时最好指定特定的文件路径(练习用的脚本,就懒得写了)
HTMLTestRunner使用可自行百度
测试报告样式: