当前位置:网站首页>Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
2022-07-05 03:49:00 【Little brother said test】
Preface
Looking for a job recently , Because it is a pure server-side test , So during the interview, the interviewer will inevitably ask , How to design interface test cases , How to do interface automation test ? I will take a symbolic test of basic skills .
Next is interface testing , Or service side testing , Sort out my thoughts ~
One 、 What is an interface
Q: What is an interface ?
A: Let's give you an example , Thirsty and want to drink water , There happens to be a water dispenser next to it , The faucet is an interface
Then the same is true in the procedure , You buy clothes on the app 、 Ordering meals 、 rent an apartment 、 Book air tickets, food, shelter and transportation , In fact, they are accessing the interface of the corresponding program .
Take the example I want to give below to illustrate :
There is a login page , You have to go to the website , You need to enter your account password , Use the account and password as the request parameter to enter the login interface , At this time, the client will send a login request to the server , After the server authentication and verification pass , Then he climbed up .
This completes an interface request , Or run an interface test case .
Two 、 What are the common types of interface requests ?
Common interface request types are :post get put delete
I usually ask get and post The difference between , Don't understand Baidu
that , Design interface test cases , First, you need the interface contract , That is, interface documents .
What does the interface document look like , Look below ~
3、 ... and 、 Example of interface document
The test function is login page :https://xxx/account/signin(url I typed the code )
Address of the interface :https://xxx/account/signin( Think about the interface and code it , After all, there is a charge )
Request mode :POST
Interface description : Login interface of a website
【 Interface input parameters 】
【 Interface to return 】
【 Interface request example 】
{
"account": "[email protected]",
"password": "191004"
}
【 Interface returns an example 】
{
"code": 0,
"msg": "",
"data": {
"name": null,
"avatar": null,
"id": "7",
"account": "[email protected]",
"role": 3
}
}
Understand the interface contract , How to design interface test cases , Please read on .
Four 、 How to design interface test cases
First you have to have a framework
The interface has been tested for several years , Sort out a use case template , For a simple reference , Incomplete welcome to add ~
So based on this set of templates , We can design the use case of login interface in the interface contract
5、 ... and 、 Design test cases based on login interface
1. Parameter checking
account
- Required : No , An empty string , Pass on null, Do not transfer this field
- String type : Pass on int Type or other type
- Length check : Suppose the scope [1-20], Less than 1、 Greater than 20, stay 1-20 Within the scope of , The pass is too long
- enumeration : nothing
password
- Required : No , An empty string , Pass on null, Do not transfer this field
- String type : Pass on int Type or other type
- Length check : Suppose the scope [1-20], Less than 1、 Greater than 20, stay 1-20 Within the scope of , The pass is too long
- enumeration : nothing
2. Parameter combination
- Correct account password , Login successful , Return the data to get the user role and user information
- Wrong account , Password pairs , Login failed ,code1
- The account number is right , Wrong password , Login failed ,code1
- Wrong account , Wrong password , Login failed ,code1
3. Business logic
- The data flow : The login account is a database member , After logging on, the interface returns data Data found for the database
- jurisdiction : Administrator account 、 Ordinary user accounts 、 Operation account number
- Account type :qq mailbox 、 Corporate mailbox or other types of mailbox , Normal login , Phone number does not support
- Whether there is logic processing for multi terminal login , Do you want to limit the maximum number of users logging in
4. Security
- The password is visible in clear text
- You can't catch it
- Login authentication , Both the front end and the service end should be done
- token timeliness
- sql Inject
5. performance
- response time 200ms
- Concurrency number ( I feel no need to consider high concurrency when logging in , Specific business scenario analysis )
6. journal
- When measuring the interface , Follow the log
7. monitor
- The interface function is online , Pay attention to business requests and various exception monitoring
6、 ... and 、 What tools are commonly used for interface testing
- postman
- jmeter
- linux command curl Send an interface request
- python、java Write the script
All of the above , The fourth one is used for interface automation testing
7、 ... and 、 Interface automation test ideas
First step : Handmade case By writing code , Turn to automated testing case, Set up case Assertion of , Then run this batch case Let him execute automatically , First, let the code run roughly
The second step : Reduce repetitive code , Integrate the test data into parametric reading , Data driven
The third step : Optimize code readability , Pull out the general module
8、 ... and 、 Interface automation test practice
Complete the first step , It's simple , Write one , Other copy and paste , Change assertion , Change parameters
So what's the problem ?
- Add a new use case , I want to change one in the code , Parameters are also placed in the code , Looks tired , It's also very tiring to change .
Complete the second step , Put use cases in excel in , adopt pytest The built-in decorator is parameterized
Here we solve the problem of changing parameters in the first step , But there are still problems
- Code duplication is large , Add another use case later , That repeated piece needs to be written again
- obtain excel The method of data is put in the test case , Poor code readability , Our test cases had better not contain preconditions .
Complete step three , Extract read excel Data section , In a separate file , Bring up the part of parameter conversion and request initiation .
At the same time, it optimizes the acquisition excel Data section , The last step is to read the area , This has poor scalability , If I want to be in excel Riga use case , You need to change this area , So let him read this column directly , This will not affect the later casually .
It's much more refreshing , Add use cases , Just change excel, And then in testcase Add use cases , And the use case basically implements assertions .
If you want to add some logs , Or you need to check the database to make assertions, and so on , It can be optimized .
It's not easy to code words , Reprint please indicate the source , thank you ~
Learning resource sharing
Finally, thank everyone who reads my article carefully , Watching the rise and attention of fans all the way , Reciprocity is always necessary , Although it's not very valuable , If you can use it, you can take it
These materials , For thinking 【 Advanced test development 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful …….
边栏推荐
- [2022 repair version] community scanning code into group activity code to drain the complete operation source code / connect the contract free payment interface / promote the normal binding of subordi
- JWT漏洞复现
- [learning notes] month end operation -gr/ir reorganization
- 测试开发是什么?为什么现在那么多公司都要招聘测试开发?
- English essential vocabulary 3400
- 天干地支纪年法中为什么是60年一个轮回,而不是120年
- postman和postman interceptor的安装
- When sqlacodegen generates a model, how to solve the problem that the password contains special characters?
- [system security] ten thousand words summary system virtualization container bottom layer principle experiment
- Nmap user manual learning records
猜你喜欢
PlasticSCM 企业版Crack
Thread Basics
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
线上故障突突突?如何紧急诊断、排查与恢复
About MySQL database connection exceptions
Smart pointer shared_ PTR and weak_ Difference of PTR
IronXL for .NET 2022.6
The architect started to write a HelloWorld
线程基础知识
Clickhouse物化视图
随机推荐
ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 1)
@Transactional 注解导致跨库查询失效的问题
Thread Basics
Nmap user manual learning records
Anti debugging (basic principles of debugger Design & NT NP and other anti debugging principles)
Binary heap implementation (priority queue implementation)
v-if VS v-show 2.0
KVM virtualization
Basic function learning 02
040. (2.9) relieved
When sqlacodegen generates a model, how to solve the problem that the password contains special characters?
Talk about the SQL server version of DTM sub transaction barrier function
Why is there a reincarnation of 60 years instead of 120 years in the tiangan dizhi chronology
天干地支纪年法中为什么是60年一个轮回,而不是120年
【软件逆向-基础知识】分析方法、汇编指令体系结构
Basic knowledge of tuples
我就一写代码的,王总整天和我谈格局...
Monitoring web performance with performance
Difference between MotionEvent. getRawX and MotionEvent. getX
Yuancosmic ecological panorama [2022 latest]