当前位置:网站首页>After reading this article, you should thoroughly understand how to do interface testing
After reading this article, you should thoroughly understand how to do interface testing
2022-07-26 01:40:00 【Xiaowu knock code】
Common project architecture

What is an interface
Interface : A unified access method provided by the server program , Usually used HTTP agreement , Through different url, Different request types (GET、POST), Different parameters , To execute different business logic .
Most of the business operations of the client , All need to call the server interface to obtain some data , Or trigger some business , Then the client gets the data returned by the interface , It will do different processing and display according to the data content .
Why do interface tests
A、 In the company , The client and server are usually developed by different teams , In the process of project development , The progress of client and server development is inconsistent , For example, the server is developed first , At this time, you can test the interface of the server first , Ensure that the server logic and return The back data is correct , Then test the client . Or some testing department , Dedicated test server development team , therefore , Their test object is the interface .
B、 When testing certain businesses , You can't just test through the front end , For example, user registration , The front end restricts that the user name cannot be empty , But some people may use tools to bypass the front end and call the server interface directly , If the server does not make relevant logical judgment , Will cause data error . Including whether key information is encrypted during interface data transmission . Therefore, the server interface must be tested separately .
C、 After development and test , You can run the interface test of the server through the tool first , Ensure that all interface test cases pass , Quickly judge whether the server interface meets the expectations . And then through UI Test the interface . Otherwise, the interface has bug, The front page must have bug.
Interface test tools and processes
common HTTP Interface testing tools include Jmeter、Postman、SoupUI etc. . What is used more in enterprises Jmeter.
Jmeter It's an open source 、 Free interface testing tools , It can control the function of the interface 、 Performance testing . Interface automation can also be realized .
Jmeter Specific use , Please refer to 《Jmeter Interface tool practice 》 file 
Interface test process :
And ordinary web The test is the same , It is also a requirement analysis first 、 Test case writing 、 Perform the test 、 Submit bug、 regression testing 、 Submit Test report, etc .
The focus of interface testing
1、 Input
Input mainly refers to the input parameters of the interface , In our usual tests , Will consider the normal input first , And abnormal input parameters , Exceptions include : Parameter exception and data exception , Use case design uses equivalence class partition and boundary value analysis
Normal input parameters
Normal input parameters are well understood , It is based on the input standard of the interface design document , Enter normal parameters , Respond according to the interface design document Return to normal under certain conditions
Parameter exception
Parameter exceptions include : The parameter is empty. , More or less participation , Wrong parameters
Data exception
Data exception : Wrong data type 、 Non null parameter is null , The length does not conform to the design , Out of range data , Illegal members , special Characters or sensitive characters , Abnormal parameter data with associated relationship, etc
2、 Business logic
And based on UI The same as the functional test , Interface testing also needs to understand the business logic behind the interface , Processing logic for business processes , We You can enter parameter constraints from 、 The action object of the event 、 Business state transition and other different dimensions
Analysis of constraints
① Numerical limits : Dictionaries , Grade , Industry related restrictions , Amount limit , Score limits, etc
② The limitation of state : It works | Invalid , On-line | offline , Pull black | Wash white, etc
③ Relationship constraints : Exist or not exist , Bind or unbind, etc
④ Limits of authority : Administrators , Ordinary users, etc
Object analysis
Object analysis is mainly used to operate legal and illegal objects , For example, bank card users recharge their cards , There may be : user A Use non users A Recharge your card ; user A Recharge with your own card , The card has expired ; user A Recharge with your own card , The card is blacklist or loss report, etc .
Analysis of state transition
Such as payment business , Pay first , There will be a refund after cancellation , Pay again if payment is unsuccessful , Payment failure , Between states Whether the switching is normal , Failure to operate smoothly according to normal business , How does the status display , Is it controllable , Whether there is an abnormal state , Empty state How to deal with business, etc
Timing analysis
In some complex activities , An activity consists of a series of actions in a specified order , These actions form an action flow , Yes, in this order , To wait until the expected results , What will the program do with other branch actions that occur during execution ?
3、 Output
When considering exceptions , Usually we think of the normal situation , Invalid situation , But it may not cover all error codes , The error code returned by the interface definition can help us supplement the use cases in this part , For example, the network is abnormal , Invalid rule , Invalid parameter , Invalid business ID, Invalid task , Server exception, etc , hold errorcode More use cases can be designed by adding the values of
The design of use cases based on the output , You can find out whether the front and rear ends output results normally , Whether the prompt is friendly , Prompt whether sensitive information appears, etc
4、 Database operation
Whether business data warehousing is normal , Whether there is duplicate data warehousing , Whether there is garbled code
Whether the data update is normal , Especially the time field , Whether the time is 24 The hour format
Whether the fields in the table meet the expectations
5、 Security
Whether sensitive information is encrypted ( Such as user name 、 Bank Account , password , Transfer amount )
6、 performance
The maximum number of concurrency supported by the interface
How many services can the interface handle per second (TPS)
The average response time of the interface (RT)
The consumption of server resources by the interface (CPU、 Memory 、 The Internet 、 disk )
7、 Compatibility
Interface testing does not need to consider the compatibility of the client , Mainly data compatibility . For example, whether the historical data of the old interface is compatible , use New interfaces to handle old data , Whether it can be handled normally .
8、 other
Idempotency : It means that the result of one or more requests for the same operation is consistent , It won't have side effects due to multiple clicks .
Let's take the simplest example :
That's payment , Users pay after they buy goods , Payment and deduction succeeded , But when the result is returned, the network is different often , At this time, the money has been deducted , The user clicks the button again , At this point, the system should refuse to pay , And prompt “ You can't pay repeatedly ”. amount to The second payment will have no effect . When doing interface tests , For some interfaces with idempotent requirements , You need to test idempotent try .
It is usually possible to use Jmeter Continuous call 2 Secondary interface for payment 、 Submit and other operations , To test idempotency .
Finally, thank everyone who reads my article carefully , The following online link is also a very comprehensive one that I spent a few days sorting out , I hope it can also help you in need !

These materials , For those who want to change careers 【 software test 】 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 ……
If you don't want to grow up alone , Unable to find the information of the system , The problem is not helped , If you insist on giving up after a few days , You can click the small card below to join our group , We can discuss and exchange , There will be various software testing materials and technical exchanges .
| Click the small card at the end of the document to receive it |
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
Self study recommendation B Stop video :
Zero basis transition software testing : Self taught software testing , Got the byte test post offer, Is the B The best video station !
Advanced automation testing : Huawei has landed , Salary increase 20K,2022 Most suitable for self-study python Automated test tutorial , Spend it yourself 16800 Bought , Free sharing
边栏推荐
- Iftnews | suppose this is what the metauniverse looks like 20 years later
- Dijkstra 求最短路
- Big view +500 cases, software teams should improve R & D efficiency in this way
- Linked list related interview questions
- Practice sharing of monorepo based on yarn1.x
- 网络之IP地址
- U++ learning notes ustruct, uenum declaration and function library simple function implementation
- Arthas watch command to view the properties of objects in the array
- FFT is used to estimate the image resampling factor after interpolation
- Server available resources query script
猜你喜欢

Integer data type in C language (do you really understand it)

Go operation excel library excel use

Leetcode 537. complex multiplication (netizens' thoughts, ashamed)

记一次自定义 Redis 分布式锁导致的故障

网络之IP地址

The best way to practice Animation: cover transition

两阶段提交和三阶段提交

聚势|海泰方圆亮相第五届数字中国建设峰会

Record a failure caused by a custom redis distributed lock
![[go] III. The simplest restful API server](/img/1f/f6fc8cc9a3891d01a25e709170188d.png)
[go] III. The simplest restful API server
随机推荐
Huawei wireless device WDS configuration command
Network layer 2 and layer 3 forwarding
“蔚来杯“2022牛客暑期多校训练营2 I.[let fat tension] 矩阵乘法 J.[Link with Arithmetic Progression]线性回归
Google gson usage details
EasyRecovery15下载量高的恢复率高的数据恢复软件
言语理解-片段阅读的结构剖析练习
快速创建题目文件夹
Case when of SQL
NodeJS 基于 Dapr 构建云原生微服务应用,从 0 到 1 快速上手指南
Leetcode 537. 复数乘法(网友思路,自愧不如)
Arthas watch command to view the properties of objects in the array
NiO simple example
Dot screen precautions
U++ learning notes ustruct, uenum declaration and function library simple function implementation
The second China rust developer conference is coming, and the complete agenda has been exposed!
Is it safe to open an account for stock speculation through the online account manager?
Dijkstra 求最短路
Special topic of distributed micro service e-commerce (I) - Project Introduction
销量连连夺冠,五菱的成功秘诀只有低价吗?
Recommend a super good UI automation tool: uiautomator2!