当前位置:网站首页>Pytest learning - dayone
Pytest learning - dayone
2022-07-07 09:53:00 【Don't ask me y】
One 、pytest Unit test framework
1、 What is a unit test framework :
In the process of software development , The smallest unit for software ( function 、 Method ) Check and test the correctness
2、 Unit test framework :pytest、unittest
3、 The main function :
- Tests found : Find the test case from the file
- The test execution : In a certain order
- Test judgment : Judge the difference between the expected results and the actual results through assertions
- Test report : speed of progress 、 Time consuming 、 Passing rate 、 Generate test reports
Two 、 The relationship between unit test framework and automation test framework
1、 What is automated testing framework
Test code encapsulated to complete the automation of a project
2、 effect
1. Improve test efficiency
2. Reduce human intervention , Improve test accuracy
3、POM Pattern 、 Data driven 、 Keyword Driven 、 Assertion 、 Log links, etc
Report mail 、selenium、request Secondary packaging of
The unit testing framework is just one part of the automation testing framework
3、 ... and 、 About pytest Characteristics
1、 Very mature python Unit framework , And ratio unittest Easier to use
2、pytest You can talk to selenium、request、qpplum In combination with implementation web automation 、 Interface automation 、app automation
3、pytest Test cases can be skipped and reruns Failed test cases
4、pytest You can talk to allure Generate very beautiful test reports
5、pytest You can talk to lenkins Continuous integration
6、pytest There are many very powerful plug-ins , And there are many operations used
pytest-html Generate html Automated test report in
pytest-xdst Distributed execution of test cases , many CPU distribution
pytest-ordering Used to change the execution order of test cases
pytest-reruns Rerun of test cases
7、 Install all plug-ins
Put all the above commands in a new directory txt In file , Input... At the terminal :
pip install -r file name .txt
Four 、 Use pytest Default test case rules and basic application
1、 The document must be marked with test_ perhaps _test ending
2、 The test case ( Class name ) Must be Test* start , And there can be no init
3、 The test method ( Method ) We must use test start
5、 ... and 、pytest How test cases run ( You can run some use cases or all use cases )
1、 Main function mode
Run all :pytest.main([’- Parameters ’])
Run the specified module :pytest Parameters Test case name
pytest main([’-vs’,‘test_login.py’])
Specify the directory :pytest main([’-vs’,./interface.testcase’])
adopt nodeid Specify the use case run :nodeid By module name 、 Separator 、 Class name 、 Method name 、 The function name consists of
pytest main([’-vs’,‘./interface.testcase( Module name )::( Class name ):: Method name ’])
2、 Command line mode
Parameters, :
-s Output the debugging information in the use case
-v Show more details
-vs The combination of these two parameters
-n Support multithreading or distributed operation
pytest main([’-vs’,./interface.testcase’,’-n=2‘])—— Two threads run , Two threads execute the use cases sequentially
–reruns:pytest main([’-vs’,./interface.testcase’,’–reruns = 2’])
-x : As long as one test case is wrong , The test stops ( Get to know )
–maxfull : Stop testing as long as one use case fails
-k “ao": Select the execution file name that contains “ao“ Some of the use cases
3、 By reading the pytest.ini Configuration file to run
pyteat.ini The configuration file is pytest The core test framework in the test framework
Location : It is usually placed in the root directory of the file
code : Must be ANSI, have access to notepad++ Modify encoding format
effect : change pytest Default behavior of
Operation rules : This configuration file will be run in any mode
6、 ... and 、pytest The order in which test cases are executed
pytest By default, it is executed from top to bottom
Adjust the execution order in actual work :
To mark ( The writing is fixed ):@pytest.mark.run(order = 1)
边栏推荐
- Lesson 1: finding the minimum of a matrix
- CDZSC_2022寒假个人训练赛21级(1)
- HCIP 第一天 笔记整理
- 大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消
- 如何成为一名高级数字 IC 设计工程师(5-2)理论篇:ULP 低功耗设计技术精讲(上)
- C# Socke 服务器,客户端,UDP
- 进程和线程的区别
- CentOS installs JDK1.8 and mysql5 and 8 (the same command 58 in the second installation mode is common, opening access rights and changing passwords)
- Dynamics 365Online ApplicationUser创建方式变更
- How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data
猜你喜欢
印象笔记终于支持默认markdown预览模式
基于智慧城市与储住分离数字家居模式垃圾处理方法
js逆向教程第二发-猿人学第一题
How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data
AI从感知走向智能认知
其实特简单,教你轻松实现酷炫的数据可视化大屏
[4g/5g/6g topic foundation -147]: Interpretation of the white paper on 6G's overall vision and potential key technologies -2-6g's macro driving force for development
Esp8266 uses TF card and reads and writes data (based on Arduino)
第一讲:寻找矩阵的极小值
[4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
随机推荐
字节跳动 Kitex 在森马电商场景的落地实践
面试被问到了解哪些开发模型?看这一篇就够了
Flex flexible layout
小程序实现页面多级来回切换支持滑动和点击操作
高斯消元
企业实战|复杂业务关系下的银行业运维指标体系建设
# Arthas 简单使用说明
Can flycdc use SqlClient to specify mysqlbinlog ID to execute tasks
Pit using BigDecimal
Impression notes finally support the default markdown preview mode
flinkcdc采集oracle在snapshot阶段一直失败,这个得怎么调整啊?
Please ask me a question. I started a synchronization task with SQL client. From Mysql to ADB, the historical data has been synchronized normally
小程序弹出半角遮罩层
Do you have a boss to help look at this error report and what troubleshooting ideas are there? Oracle CDC 2.2.1 flick 1.14.4
nlohmann json
CodeForces - 1324D Pair of Topics(二分或双指针)
Guys, how can mysql-cdc convert the upsert message to append only
How to become a senior digital IC Design Engineer (5-2) theory: ULP low power design technology (Part 1)
The applet realizes multi-level page switching back and forth, and supports sliding and clicking operations
flink. CDC sqlserver. You can write the DEM without connector in sqlserver again