当前位置:网站首页>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()
边栏推荐
- No statements may be issued when any streaming result sets are open and in use on a given connection
- Tianrunyun, invested by Tian Suning, was listed: its market value was 2.2 billion Hong Kong, and its first year profit decreased by 75%
- 《数据安全法》出台一周年,看哪四大变化来袭?
- Oracle和JSON的结合
- Mysql的四个隔离级别是如何实现的 (简要)
- Whether lending a bank card to others constitutes a crime
- CVPR 2022 | Virtual Correspondence: Humans as a Cue for Extreme-View Geometry
- Export and import of incluxdb on WIN platform
- Packet mode and three streaming modes in SDP protocol
- Graduation season · advanced technology er
猜你喜欢

Face detection and recognition system based on mtcnn+facenet

为什么一定要从DevOps走向BizDevOps?

Technology sharing | introduction to linkis parameters

“目标检测”+“视觉理解”实现对输入图像的理解及翻译(附源代码)

英特爾實驗室公布集成光子學研究新進展

Unittest框架中跳过要执行的测试用例

CVPR22 |CMT:CNN和Transformer的高效结合(开源)

Huawei Equipment configure les services de base du réseau WLAN à grande échelle

Mingchuang plans to be listed on July 13: the highest issue price is HK $22.1, and the net profit in a single quarter decreases by 19%

Cvpr22 | CMT: efficient combination of CNN and transformer (open source)
随机推荐
Mutual conversion of pictures in fluent uint8list format and pictures in file format
I'd like to know where I can open an account in Guangzhou? Is it safe to open an account online now?
Unittest 框架介绍及第一个demo
NeurIPS 2022 | 细胞图像分割竞赛正式启动!
Mysql的四个隔离级别是如何实现的 (简要)
Internal control of fund managers
Valgrind usage of memory leak locating tool
达梦数据冲刺科创板:拟募资24亿 冯裕才曾为华科教授
[paper reading] trajectory guided control prediction for end to end autonomous driving: a simple yet strong Ba
Oracle和JSON的結合
Applymiddleware principle
Google's new paper Minerva: solving quantitative reasoning problems with language models
TEMPEST HDMI泄漏接收 3
Unittest框架中跳过要执行的测试用例
个人商城二开逍遥B2C商城系统源码-可商用版/拼团拼购优惠折扣秒杀源码
The first anniversary of the data security law, which four major changes are coming?
Handling distributed transactions with powerful dbpack (PHP tutorial)
Tempest HDMI leak receive 5
为什么一定要从DevOps走向BizDevOps?
CVPR 2022 | Virtual Correspondence: Humans as a Cue for Extreme-View Geometry