UnitTest自动化测试框架生成自动化测试报告
更新时间:2022-06-23 09:12:41 作者:多测师 浏览:15
1、HTMLTestRunner安装
使用如下命令安装即可:
pip install caterpillar-HTMLTestRunner
2、HTMLTestRunner使用
比如test01.py中测试用例代码如下:
import unittest
class TestDemo01(unittest.TestCase):
def test_01(self):
print("in test_01...")
def test_02(self):
print("in test_02...")
def test_03(self):
print("in test_03...")
测试套文件中代码如下:
import unittest
import os
from demo.test01 import TestDemo01
from HTMLTestRunner import HTMLTestRunner
report_title="测试报告标题"
report_desc="测试报告描述"
report_path="./report"
report_file=os.path.join(report_path,"report.html")
if not os.path.exists(report_path):
os.mkdir(report_path)
suite = unittest.TestSuite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestDemo01))
with open(report_file ,"wb") as report:
runner = HTMLTestRunner(stream=report, title=report_title, description=report_desc)
runner.run(suite)
以上内容为大家介绍了UnitTest自动化测试框架生成自动化测试报告,本文由多测师亲自撰写,希望对大家有所帮助。了解更多自动化测试相关知识:https://www.aichudan.com/xwzx/
上一篇:自动化测试如何避开图片验证码?