1)在测试目录下新建testhtmles.py并写入代码
import unittest
from unittestone.unittestdemo import Test_class
from data.HTMLTestRunner import HTMLTestRunner
class UseHtml():
def use_html(self):
suite = unittest.TestSuite()
case_list = ["test01","test02"]
for case in case_list:
suite.addTest(Test_class(case))
with open("../report.html","wb") as f:
HTMLTestRunner(
stream=f,
title="测试",
description="num1",
verbosity=2
).run(suite)
t = UseHtml()
t.use_html()
2)调用函数生成测试报告的html
3)打开html看效果
修改xml或csv中的数据使其失败