当前位置:网站首页>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 …….
边栏推荐
- [web source code code code audit method] audit skills and tools
- Redis source code analysis: redis cluster
- 企业级:Spire.Office for .NET:Platinum|7.7.x
- Clickhouse物化视图
- [groovy] string (string injection function | asBoolean | execute | minus)
- New interesting test applet source code_ Test available
- [groovy] loop control (number injection function implements loop | times function | upto function | downto function | step function | closure can be written outside as the final parameter)
- Easy processing of ten-year futures and stock market data -- Application of tdengine in Tongxinyuan fund
- 程序员的视力怎么样? | 每日趣闻
- 【web審計-源碼泄露】獲取源碼方法,利用工具
猜你喜欢
New interesting test applet source code_ Test available
Leetcode92. reverse linked list II
SPI and IIC communication protocol
Redis6-01nosql database
C # use awaiter
Redis source code analysis: redis cluster
Multimedia query
The latest blind box mall, which has been repaired very popular these days, has complete open source operation source code
Subversive cognition: what does SRE do?
Blue Bridge Cup single chip microcomputer -- PWM pulse width modulation
随机推荐
Monitoring web performance with performance
Redis source code analysis: redis cluster
Quick start of UI component development of phantom engine [umg/slate]
Talk about the SQL server version of DTM sub transaction barrier function
In MySQL Association query, the foreign key is null. What if the data cannot be found?
深度学习——LSTM基础
有個疑問 flink sql cdc 的話可以設置並行度麼, 並行度大於1會有順序問題吧?
一文带你了解BI的前世今身与企业数字化转型的关系
Web components series (VII) -- life cycle of custom components
JWT vulnerability recurrence
[web source code code code audit method] audit skills and tools
grandMA2 onPC 3.1.2.5的DMX参数摸索
問下,這個ADB mysql支持sqlserver嗎?
Clean up PHP session files
About MySQL database connection exceptions
v-if VS v-show 2.0
[deep learning] deep learning reference materials
UI自动化测试从此告别手动下载浏览器驱动
Why do some programmers change careers before they are 30?
反絮凝剂-氨碘肽滴眼液