当前位置:网站首页>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()
边栏推荐
- 银行卡借给别人是否构成犯罪
- Cvpr22 | CMT: efficient combination of CNN and transformer (open source)
- Shangtang entered the lifting period: the core management voluntarily banned and strengthened the company's long-term value confidence
- 编译调试Net6源码
- Brief analysis of edgedb architecture
- The first anniversary of the data security law, which four major changes are coming?
- Unittest框架中跳过要执行的测试用例
- Network security learning notes 01 network security foundation
- Paxos 入门
- No statements may be issued when any streaming result sets are open and in use on a given connection
猜你喜欢
随机推荐
Brief analysis of edgedb architecture
kafuka学习之路(一)kafuka安装和简单使用
Intel Labs annonce de nouveaux progrès en photonique intégrée
The first anniversary of the data security law, which four major changes are coming?
TEMPEST HDMI泄漏接收 5
BAIC bluevale: performance under pressure, extremely difficult period
Huawei Equipment configure les services de base du réseau WLAN à grande échelle
No statements may be issued when any streaming result sets are open and in use on a given connection
JS foundation -- data type
Oneconnect plans to be listed in Hong Kong on July 4: a loss of nearly 3 billion in two years, with a market capitalization evaporation of more than 90%
Spam filtering challenges
The idea runs with an error command line is too long Shorten command line for...
Global filter (processing time format)
Uncover the secrets of new products! Yadi Guanneng 3 multi product matrix to meet the travel needs of global users
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
Export and import of incluxdb on WIN platform
MySQL in and not in() empty list error
【MAUI】为 Label、Image 等控件添加点击事件
谷歌新论文-Minerva:用语言模型解决定量推理问题
Dameng data rushes to the scientific innovation board: it plans to raise 2.4 billion yuan. Feng Yucai was once a professor of Huake








