当前位置:网站首页>Introduction to unittest framework and the first demo
Introduction to unittest framework and the first demo
2022-07-01 11:12:00 【Field test record】
1、 effect : Manage test cases 、 Assertion 、 Generate test reports
2、Unittest Official document : Look at grammar and usage , You can also see online tutorials
unittest — Unit testing framework — Python 3.10.5 documentation
3、 Part of the
test fixture: Test fixed components
test case: The test case , The smallest unit of test execution
test suite: test suite , It is a use case set , It is used to summarize the test cases that should be executed together
test runner: Test runner , It is the component that designs the test execution mode , It provides a way to display the output results , You can use icons 、 Text 、html Way to show the test results

TestFixture Fusion runs in code , Embodied in TestCase in
4、unittest stay python3 in , yes python Built in module of , It can be used without installation
example :

5、 Modify the operation mode
1) The above figure is the default unittest Way of execution

The default operation mode can be selected as follows :
2) Normal mode execution
choice edit configuration


Select the content of the plus sign. Just look at the previous figure

apply After that , Look at the execution mode in the upper right corner of the page and change it to normal mode

The above figure is executing 2 There are two points below , Prove the execution is successful
E Represents execution error , The script is wrong, and the program is wrong
F Delegate execution failed
6、unittest Runtime , Points needing attention
Unittest Running test cases , It has to be inherited TestCase Method , And this method defaults to test start , The default execution order is test The following characters follow ASCII Code size execution
# Guide pack
import unittest
# Create inheritance unittest.TestCase Class
class FirstDemo(unittest.TestCase):
# Create test cases
def test01(self):
print(" perform 1")
def test02(self):
print(" perform 2")
if __name__ == '__main__':
unittest.main()
边栏推荐
- LeetCode. 515. Find the maximum value in each tree row___ BFS + DFS + BFS by layer
- 商城小程序源码开源版-可二开
- TEMPEST HDMI泄漏接收 5
- Uncover the secrets of new products! Yadi Guanneng 3 multi product matrix to meet the travel needs of global users
- JS基础--数据类型
- 索引失效的几种情况
- 基金管理人的内部控制
- Tempest HDMI leak receive 5
- Unittest框架中测试用例编写规范以及如何运行测试用例
- LeetCode.每日一题 剑指 Offer II 091. 粉刷房子 (DP问题)
猜你喜欢

The first anniversary of the data security law, which four major changes are coming?

Network security learning notes 01 network security foundation

Face detection and recognition system based on mtcnn+facenet

Node version manager NVM installation and switching

十年磨一剑:蚂蚁集团可观测性平台 AntMonitor 揭秘

【MAUI】为 Label、Image 等控件添加点击事件

软件项目管理 9.2.软件项目配置管理过程

Spam filtering challenges

Intel Labs annonce de nouveaux progrès en photonique intégrée

Technology sharing | introduction to linkis parameters
随机推荐
毕业季·进击的技术er
Oracle和JSON的結合
LeetCode. One question of the day: offer II 091 Paint the house (DP problem)
Global filter (processing time format)
Website source code whole site download website template source code download
Graduation season · advanced technology er
Yoda unified data application -- Exploration and practice of fusion computing in ant risk scenarios
京东与腾讯续签合作:向腾讯发行A类股 价值最高达2.2亿美元
银行卡借给别人是否构成犯罪
Uncover the secrets of new products! Yadi Guanneng 3 multi product matrix to meet the travel needs of global users
Face detection and recognition system based on mtcnn+facenet
华为设备配置大型网络WLAN基本业务
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
The exclusive collection of China lunar exploration project is limited to sale!
商汤进入解禁期:核心管理层自愿禁售 强化公司长期价值信心
Harbor webhook从原理到构建
CVPR 2022 | self enhanced unpaired image defogging based on density and depth decomposition
JS日期格式化转换方法
提问:测试工程师应该具备哪些职业素养?
Flip the array gracefully