当前位置:网站首页>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 …….

边栏推荐
- Installation of postman and postman interceptor
- Une question est de savoir si Flink SQL CDC peut définir le parallélisme. Si le parallélisme est supérieur à 1, il y aura un problème d'ordre?
- Flex flexible layout
- Is there any way to change the height of the uinavigationbar in the storyboard without using the UINavigationController?
- ICSI213/IECE213 Data Structures
- Monitoring web performance with performance
- ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 1)
- [wp][入门]刷弱类型题目
- DECLARE_ WAIT_ QUEUE_ HEAD、wake_ up_ Interruptible macro analysis
- Basic function learning 02
猜你喜欢

Easy processing of ten-year futures and stock market data -- Application of tdengine in Tongxinyuan fund

VM in-depth learning (XXV) -class file overview

一文带你了解BI的前世今身与企业数字化转型的关系

【web源码-代码审计方法】审计技巧及审计工具
![[groovy] groovy environment setup (download groovy | install groovy | configure groovy environment variables)](/img/99/bb05b6c48a9e70ca7ff77733d954b9.jpg)
[groovy] groovy environment setup (download groovy | install groovy | configure groovy environment variables)

IronXL for .NET 2022.6

Subversive cognition: what does SRE do?
![Quick start of UI component development of phantom engine [umg/slate]](/img/8b/cee092ec1ab105a7e234143bd56861.jpg)
Quick start of UI component development of phantom engine [umg/slate]

Timing manager based on C #

ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
随机推荐
【web源码-代码审计方法】审计技巧及审计工具
Analysis of dagger2 principle
Clickhouse物化视图
Smart pointer shared_ PTR and weak_ Difference of PTR
Quick start of UI component development of phantom engine [umg/slate]
VM in-depth learning (XXV) -class file overview
企业级:Spire.Office for .NET:Platinum|7.7.x
一文带你了解BI的前世今身与企业数字化转型的关系
Technology sharing swift defense programming
v-if VS v-show 2.0
An elegant program for Euclid‘s algorithm
postman和postman interceptor的安装
Blue Bridge Cup single chip microcomputer -- PWM pulse width modulation
Multi person online anonymous chat room / private chat room source code / support the creation of multiple chat rooms at the same time
Class inheritance in C #
Nmap user manual learning records
Necessary fonts for designers
Clickhouse同步mysql(基于物化引擎)
[groovy] string (string splicing | multi line string)
glibc strlen 实现方式分析