当前位置:网站首页>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 .
边栏推荐
- Handwriting promise [03] - realize multiple calls and chain calls of then method
- 学好C语言从关键字开始
- FMT package usage of go and string formatting
- Exchange two values without introducing the third variable
- 不同VLAN间的通信
- UEFI finding PCI devices
- PHP laravel8 send email
- Analyze the principle of configuration center from the perspective of Nacos client
- JS implementation of Hill sort of graphic insertion sort [with source code]
- 2021-03-25
猜你喜欢

563. slope of binary tree

Shandong University machine learning experiment 5 SVM

Examinelistactivity of Shandong University project training
![Illustrate the principle of one-way linked list and the method of JS to realize linked list [with source code]](/img/0d/2de3413fcb77ac2bd093677035f2e7.jpg)
Illustrate the principle of one-way linked list and the method of JS to realize linked list [with source code]

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

Jenkins user rights management

Solve the problem that ffmpeg obtains aac audio files with incorrect duration

双周投融报:资本抢滩元宇宙游戏

The realization of online Fox game server room configuration battle engagement customization function

Jenkins voucher management
随机推荐
QT socket setting connection timeout
Who is stronger, zip or 7-Zip, and how to choose?
On cursor in MySQL
JVM from getting started to giving up 2: garbage collection
Implementation of customization function page of online Fox game server room configuration wizard service
Make a small game with R language and only basic package
UEFI finding PCI devices
JS implementation of graphic merging and sorting process [source code attached]
arguments......
SQL语言-查询语句
动态import
MMEditing中超分模型训练与测试
不引入第三个变量,交换两个值
On the social moral and ethical issues behind short videos (personal point of view, for reference only)
How to treat the ethical issues arising from driverless Technology
JS judge whether the year is a leap year and the number of days in the month
Won't virtual DOM be available in 2022? Introduction to virtual Dom and complete implementation of diff and patch
Shandong University machine learning final 2021
021 mongodb database from getting started to giving up
617. merge binary tree