当前位置:网站首页>Unittest unit test (III)
Unittest unit test (III)
2022-04-21 13:49:00 【Effort volume】
6、 ... and 、unittest Test case running results
. On behalf of success
F For failure
E Represents a mistake
S For use cases, skip
Cannot pass -v How to run . Because this is a detailed error reporting method , Instead of a concise error reporting method
7、 ... and 、unittest Execution sequence rules of test cases
With ASCII Sort the size of the code .【0-9,A-Z,a-z】
adopt ord('a) see ASCII code
8、 ... and 、 Varied unittest How to load and run test cases
1、mian Method
2、 Load and run through the test suite
addTest
# Create a test suite
if __name__ == '__main__':
suite = unittest.TestSuite()
# Load test cases through the test suite
suite.addTest(TestUnittest('test_01'))
suite.addTest(TestUnittest('test_02'))
# function defaultTest Specify Kit
unittest.main(defaultTest='suite')
addTests
# Create a test suite
if __name__ == '__main__':
suite = unittest.TestSuite()
# Load test cases through the test suite collection
testcases = [TestUnittest('test_01'),TestUnittest('test_02')]
suite.addTests(testcases)
# function defaultTest Specify Kit
unittest.main(defaultTest='suite')
3、 Load all test cases in a directory
if __name__ == '__main__':
suite = unittest.defaultTestLoader.discover('./test', pattern='*.py')
unittest.main(defaultTest='suite')
Why we call unittest.main() You can execute test cases ???
Underlying principle ,BATJ Interview questions of large factories
ctrl+ Left mouse button to enter main()

module: The path where the test case is located ,__main__ Represents the current path defaultTest: The default name of the test case to be tested , All use cases are executed by default argv: Accept parameters passed externally to the program testRunner: Test runner testLoader: Test loader exit: Whether to exit the program after the test is completed verbosity: Display the detail level of the information (<=0 Only the total number of use cases and the global execution results are displayed ,1 The default value is , Displays the total number of use cases and global results , And the result of each use case is marked, that is
. On behalf of success
F For failure
E Represents a mistake
S For use cases, skip
>=2 Show use case overview and global results , And output the detailed results of each use case ) verbose -v failfast: Whether to terminate the test when the test case fails .
版权声明
本文为[Effort volume]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211347166961.html
边栏推荐
- mysql-MVCC多版本并发版本控制和bufferPool缓存机制
- NPM - environment
- Example: use C # NET teaches you to do WeChat official account development (7) -- location message for general message processing.
- Machine learning notes - SVD singular value decomposition (3) applying SVD to images
- In office word 2016, omml2mml appears when the formula edited by word's own formula editor is transferred to MathType Solutions to XSL problems
- Tailwind core concept - responsive design
- Buuctf [Chapter 3 Advanced Web] logic vulnerability
- If the field lines are the same, they will be merged into another field SQL statement?
- BOM development of access (3) BOM expansion
- An example of expert system and its skeleton system
猜你喜欢

metasploit渗透

Wechat hidden function series: wechat regular reminder, 2 steps, to relax yourself when you are busy

CV technical guide free knowledge planet

Peking University ACM problems 1009: edge detection

并发编程之JMM模型和并发三大特性

If the field lines are the same, they will be merged into another field SQL statement?

實現隨機標簽,字體大小、顏色隨機顯示

JVM字节码文件结构深度剖析

基于VScode的ESP32开发学习(五):用户自定事件循环详解,dedicated task

Unittest单元测试(五)
随机推荐
Access的BOM开发(3)BOM展开
MySQL学习笔记-day03
SECOND: Sparsely Embedded Convolutional Detection
Markdown grammar and test
EsgynDB 清理不一致对象
Wechat hidden function series: wechat regular reminder, 2 steps, to relax yourself when you are busy
tooltip显示更多的信息
Scroll bar style modification
metasploit渗透
Longest common subsequence (I) (dynamic gauge)
npm---package.json
EsgynDB 关于带索引的DELETE性能提升
CDH5删除数据节点
Unittest单元测试(二)
Example: use C # NET teaches you to do WeChat official account development (7) -- location message for general message processing.
npm---环境
Peking University ACM problems 1012: Maya calendar
EsgynDB 关于收集core信息的小技巧
Vagrant详细教程
Ipemotion collects J1939 protocol signal