UnitTest自动化测试框架生成自动化测试报告(图)

测试工具 创建于:2022-06-17
  
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)

  执行完成后生成测试报告用
浏览器打开如下:



  
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系51Testing小编(021-64471599-8017),我们将立即处理

21天更文挑战,赢取价值500元大礼,还有机会成为签约作者!

原文地址:http://www.51testing.com/?action-viewnews-itemid-7789496

免责声明:本文来源于互联网,版权归合法拥有者所有,如有侵权请公众号联系管理员

* 本站提供的一些文章、资料是供学习研究之用,如用于商业用途,请购买正版。

发表于:2022-6-17 09:33 作者:Redrose2100 来源:稀土掘金