当前位置:网站首页>Pytest automated test - easy tutorial (01)
Pytest automated test - easy tutorial (01)
2022-06-11 06:43:00 【zhulixinxikeji】
What we are going to talk about today , Is the testing framework Pytest, Speaking of this testing framework, I haven't done Web For automation partners , Will feel this thing is strange , So what exactly is a framework ? What is automation ? Why should automation use frameworks ?
Don't I just learn automation Python+Selenium perhaps +Appium Is that all ?
What is the function of this framework ?
In the middle of this process , Let me tell you about automated testing first ,
So called automated testing , You can understand that it is actually the same as the function test process , For example, when we do functional tests , What do you need to do ?
You need to analyze the needs .
A functional test : Analyze requirements ==》 Design of use cases ==》 Execute test cases manually ==》Bug Submission of ==》 Test report
When we do functional testing, we should first analyze the requirements , Then we need to design use cases , In addition, execute the use cases manually , Then, we also have to carry out Bug A submission for , If you come across Bug We are going to submit Bug, End of submission Bug after , After testing a version or a phase, we will issue a test report . Basically, for our functional testing, it is such a process .
automated testing ( Analyze requirements ==》 Design automation use case control ==》 Code ( Tools ) Execute use cases )==》 Test report
In fact, automated testing is also a part of this process , First, we will also analyze the requirements , But the analysis requirements , It refers to your needs for the whole project business , And process requirements . I want to determine which businesses are involved in this project 、 Processes can be automated , What cannot be achieved , What can be achieved is done automatically , If you can't do it, do it by hand . So in the first stage, we all do demand analysis , Then in this area, you need to design automated test cases after you determine the requirements , In this , What do we mean by automation ?
That is to say, we use code or tools instead of human to execute the process of this use case , So it's automated testing .
Because in the middle of the functional testing work , Originally, we did it by hand , Click input and other operations , Only in the automation process, code or tool methods are used to replace .
How the code tool executes , How to judge , How to submit test reports , So we write all these things in the middle of the code , Because in the middle of this process , Since you have written so many test cases , When the code is implemented, we will also cover the automated test cases , So as to realize . The test report will be issued later , But this test report doesn't need you to make statistics manually .
For example, I make statistics manually , How many altogether Bug,A How many classes are ,B How many classes are ,C How many classes are , Whether the test result is passed or not , This is the way we make statistics when we do function tests , To measure .
But when doing automated testing , We can also use the form of code , Let it generate the specified test report , In the middle, you will automatically count how many test cases are successful and how many test cases are failed ( Wrong )
So in this area, functions and automated processes , The biggest difference is in the code ( Tools ) Execute the use case
So if we want to use code or tools , To cover or complete all automated test cases , How do we do it ?
Are they all done in a linear process ?
Linear process : Open the browser -- Enter the login interface -- enter one user name -- Input password -- Click login
Sign in
1: Correct user name Admin, The right password -123456 ==》 result ==》 Write it in the test report
2: Wrong user name User, Wrong password -1234567890
3……
Whether it's your first or second use case , What it does is a linear process like the previous one , What is the biggest difference between them ?-
The biggest difference is the data :
- For example, the correct user name Admin - 123456
- If I'm wrong, I'll do it User, Password matching 123456
- Or the correct user name Admin, Match a wrong password 1234567890
So here we have to consider , How to maximize the reuse of scripts , As long as it is implemented through different data OK, And after each use case is executed , It will automatically generate corresponding results for you , Write it in the middle of our test report . Because we finally judge whether you pass the automated test or not by the results in the test report .
So in this case , How to solve this problem of use case coverage , So I have to tell you , We need to address use case coverage , It's ours
Unit test framework
For example, we often
- Java——junit
- Python——unittest / Pytest
These frameworks are designed to standardize the coverage of automated test cases , And reuse scripts to the greatest extent .
In the middle of the process , The unit test framework can not only be used in the middle of our automated test process , It can also be used as a white box test in the unit phase , This means that we test engineers do not have much contact with this part of the work , Because among enterprises , Most white box tests are done by developers . Just say that if you master this thing , Besides, we can use it in automation , It can also be used in unit white box testing .
What I want to tell you today is Pytest.
unittest / Pytest What's the difference? ?
Let's briefly explain ,
The first thing they have in common is that they are both mainstream unit testing frameworks
Some friends, like him, only know one of them , For example, you will Pytest But it won't work Unittest.
In fact, this is also an interview question : Why do you use this one instead of the other ,unittest / Pytest What's the difference? ?
In our learning process , Since these two are the mainstream , Basically, we have to know both frameworks .
Unittest yes Python It comes with a unit testing framework , and Pytest Is a third-party framework , This is the first difference between the two .
The difference between the built-in framework and the third-party framework ?
The self-contained does not need to be installed , You can use it directly , Third party you have to install first .
Second difference ,Unittest In fact, there is no function of Pytest So powerful , because Pytest It has many plug-ins , And the overall situation is very good .
The third difference ,Pytest The implementation will be better than Unittest More concise , Lighter .
So when we build an automation framework among enterprises , In fact, I will choose Pytest More than that Unittest.
however Unittest For beginners , It is also a very good framework .
边栏推荐
- go的fmt包使用和字符串的格式化
- 核查医药代表备案信息是否正确
- 022-Redis数据库0基础入门
- socket. IO cross domain stepping pit
- 争议很大的问题
- Sohu employees encounter wage subsidy fraud. What is the difference between black property and gray property and how to trace the source?
- How to treat the ethical issues arising from driverless Technology
- What are the differences and usages of break and continue?
- EasyGBS接入的设备视频直播突然全部无法播放是为什么?数据库读写不够
- Who is stronger, zip or 7-Zip, and how to choose?
猜你喜欢

Shandong University machine learning experiment 7 pca+ SVM face recognition

617. merge binary tree

Communication between different VLANs

Teach everyone how to implement an electronic signature

关于 QtCreator的设计器QtDesigner完全无法正常拽托控件 的解决方法

Jenkins different styles of project construction

Markdown + typora + picgo experimental report template attached

Won't virtual DOM be available in 2022? Introduction to virtual Dom and complete implementation of diff and patch

Metasploitabile2 target learning

通过R语言且只用基础package来制作一个小游戏
随机推荐
617. merge binary tree
Oracle提示无效数字
Markdown + typora + picgo experimental report template attached
Detailed explanation of mutual call between C language and Lua
搜狐员工遭遇工资补助诈骗 黑产与灰产有何区别 又要如何溯源?
Vulnhub's breach1.0 range exercise
instanceof到底是怎样判断引用数据类型的!
QT socket设置连接超时时间
Mediaextractor source code analysis of multimedia framework analysis (1)
关于parseInt()
Wan Zichang's article shows you promise
CCS method of installing compiler
fatal: refusing to merge unrelated histories
Error code in ijkplayer
Resolve typeerror: ctx injections. tableRoot.$ scopedSlots[ctx.props.column.slot] is not a function
ijkPlayer中的错误码
Quantitative understanding (Quantitative deep revolutionary networks for effective information: a whitepaper)
C语言大战“扫雷”
347. top k high frequency elements
Count the time-consuming duration of an operation (function)