当前位置:网站首页>使用unittest框架生成测试报告
使用unittest框架生成测试报告
2022-06-21 16:00:00 【爆肝拳专业户】
生成测试报告
案例代码:
Testcase.py文件:
import unittest
class Test_case(unittest.TestCase)#继承TestCase类:
#起始
def setUp(self):
print('所有用例执行开始!!!')
#结束
def tearDown(self):
print('所有用例执行结束!!!')
def test_ab(self):
print('ab用例执行-------')
a = 1
b = 1
#用断言判断a与b是否相等
self.assertEqual(a,b,'a与b相同')
def test_cd(self):
c=7
d=1
print('cd用例执行--------')
self.assertEqual(c,d,'c与d不一致')
Testsuit.py文件:
import unittest
from HTMLTestRunner import HTMLTestRunner
from AA.Testcase import Test_case
#构造测试套件(测试流)
testsuite=unittest.TestSuite()
#添加测试用例
testsuite.addTest(Test_case('test_ab'))#调用Test_case类的test_ab方法
testsuite.addTest(Test_case('test_cd'))#调用Test_case类的test_cd方法
#创建report.html测试报告
file=open('./report.html','wb')
runner=HTMLTestRunner(stream=file,title='测试报告',description='执行报告')
runner.run(testsuite)
file.close()
生成的测试报告:
边栏推荐
- Can Koufu open a futures account? Is it safe?
- Kindeditor uploading pictures and using
- Which futures company is better to open an account at present? Is the service charge low and the transaction safe?
- 7 tips for writing effective help documents
- 叩富网可以开期货账户吗?安全吗?
- Reinforcement learning introductory project spinning up (1) installation
- 谷歌 Chrome 浏览器全新下载窗口将支持文件拖拽,Edge 已经支持
- "Forget to learn again" shell process control - 36. Introduction to the for loop
- 之前的装机记录
- 依靠可信AI的鲁棒性有效识别深度伪造,帮助银行对抗身份欺诈
猜你喜欢

The release of autok3s v0.5.0 continues to be simple and friendly

撰写有效帮助文档的7大秘诀

海外new things | 美国人工智能初创「Zoovu」新一轮融资1.69亿美元,为消费者优化线上的“产品发现”体验

Cisco(59)——Hub&Spoke MPLS

云原生之混合云网络互联

快来围观–TPT18新版报到

In 2022, the number of mobile banking users in Q1 will reach 650million, and ESG personal financial product innovation will be strengthened

Huawei (13) - route introduction

Implementation and landing of any to any real-time voice change RTC dev Meetup

Cisco(35)——BGP入门实验
随机推荐
站在数字化风口,工装企业如何“飞起来”
Cisco (35) -- BGP introduction experiment
Cisco(59)——Hub&Spoke MPLS
HUAWEI(13)——路由引入
关于印发《北京市共有产权住房管理暂行办法》的通知
期货农产品开户怎么开?手续费是多少?
云原生之混合云网络互联
Serious illness insurance covers serious illness. Which product is the best in the market? Please recommend it
天天预约排队助手|使用手册
D improve translation
Google Earth Engine(GEE)——sentinel-1综合查看两个月前后自动滑坡监测,两者之间的差异(危地马拉为例)
撰写有效帮助文档的7大秘诀
Machine learning model monitoring (Apria)
[1108. IP address invalidation]
之前的装机记录
[1108. Invalidation de l'adresse IP]
Some understanding of cookies and sessions
聪明人:三不管、四不说、五不帮,古人为人处世之道
关于产品运营策略
Focusing on industrial intelligence scenarios, Huawei cloud recruits partners to help solve transformation problems