1.导入unittest模块,和HTMLTestRunner。
2.告知需要执行所有用例所在的文件位置。 例如: case2Pate = “D:\\xuexi\\xue\\case2”
3.使用discover 确定需要执行的地址,和所有需要执行的用例格式 命令: discover = unittert.defaultTestLoader.discover(case2Path, "test*.py)
4.告知生成的测试报告存放的位置。 如: reporPath = “D:\\xuexi\\xue\\report\\"+ "result.html”
5. 把生成的数据,写入文件中 命令:fp = open(reporPath, “wb”)
6.执行命令:
runner = HTMLTestRunner.HTMLTestRunner(fp, verbosity=2,title="发布订单报告", description="这是一个HML格式的报告") title为标题,description为描述
runner.run(discover)
fp.close()
HTMLTestRunner.py插件链接如下:
链接:https://pan.baidu.com/s/1UZp5RsYZx18Yg794Ny33OA 密码:p3s0