当前位置:网站首页>How to test interfaces that depend on third parties?
How to test interfaces that depend on third parties?
2022-07-21 23:29:00 【Pot talk soft test】
I encountered this situation in the project before ,1. Docking with third parties , During the joint debugging , If the other party's interface has not been developed yet , But there are interface documents , Need simulation .2. And that is Common calls for wechat payment 、 In the case of Alipay payment , Need simulation .
When we are doing interface testing , You need to simulate this part of the test , Suppose that the interface of the third party is completely implemented according to the interface document , Then we can use postman To carry out mock( Generally used in test environments ), And others moco Open source framework (
moco-runner-0.12.0-standalone.jar) Can be realized .
Postman Of Mock Servers Function use
Have you ever encountered the following situations :
1. The back-end code is not yet developed , The front-end code needs to call the back-end interface for debugging , What should I do ?
2. Unable to control the return of an interface of a third-party system , The data returned does not meet the requirements of ?
3. Joint debugging with a third party is required, but the other party has not yet developed , How to test your code in advance ?
With the above questions , Let's see what is Mock?
Mock: Fake objects that simulate the behavior of real objects in a controllable way , According to your actual needs Return the data you want .
Use at the same time mock The premise of : There should be perfect interface documents ,URL、 Request mode 、 Request parameters 、 Returns the parameter 、 Error code , In this way, different return data can be created according to the actual business needs .
Postman-Mock Servers It's a good solution to this problem , It can mock Simulate the return value of the dependent interface , In this way, you can focus on testing the current interface .
Let's introduce Postman Of Mock Servers Use :
1. download Postman,Postman The first is function chrome Browser plug-in exists , Now? Postman Provides a separate installation package , No longer dependent on Chrome Browser . Support at the same time MAC、Windows and Linux, It is recommended that you use this method to install . Download address :https://www.postman.com/ ( My locally installed version is :Postman for Windows Version 9.5.0 )
2. open postman , Click on the left side of the Mock Servers
step :Mock Servers --> New --> Mock Server
Added 2 Interface , Query completed orders and cancelled orders (get request )
Created Mock Server Go to the following interface :
3. Click on the left Collections Click on MockTest, Yes 2 Interface , And automatically generated examples The following screenshots :
4. We can send the request through the following link , Copy url, Click on send, You can see the return message
5. Want to modify the interface information filled in before , Click on eg-default, Such as 1 It's about , Edit content :a. Add a new input parameter fgdel b.response Add return field -addComent, After revising , preservation .
Copy the link above URL, Create a new one request, Click on send, You can get the latest response Information , as follows :
6.url Yes 2 Access mode
The first one is :{ {url}}//orderlist?status=1&fgdel=0 ( url by postman The environment variable selected on the right )
The second kind :Copy mock url + route , as follows , It can be accessed directly on the browser
https://62ae1da0-14b3-4dfc-a68a-731275c60cff.mock.pstmn.io//orderlist?status=1&fgdel=0
7. What needs to be noted here is :
Every request There can be multiple example
Every example It can be modified after creation
Mock server Only the last created example
preservation example, Be sure to set the corresponding example And then run the newly created request after saving , Otherwise, the returned result will report an error .
All of the above are get request , Here's a demonstration of post Requested mock, The steps are the same , Let's see eg:
It can also be done through Flask,Django To implement the interface Mock service .
边栏推荐
- Analysis of Excel file
- Read and write of zip file
- Mongodb complex query instance (nested multiple arrays and regular expressions)
- Datart open source data visualization application | teach you to develop excellent chart plug-ins
- Watermelon book chapter 2 - Comparative Test
- MGRE experiment
- HCIP第九天
- 【无标题】HCIP第一天笔记
- HCIP第十天
- MGRE experiment
猜你喜欢
How to record game interface in unity editor
Watermelon book chapter 3 - linear model
On the fifth day, OSPF packets
HCIA learning ideas
Dry goods | data fragmentation problem of distributed system
Mongodb complex query instance (nested multiple arrays and regular expressions)
MGRE实验
MCU demand of smart meters and ranking of meter chip manufacturers
关于char str[20]=““ 和 char str[20]=“ “
第六天区域划分及LSA
随机推荐
The market scale of 300million chips competes, and the inventory of domestic ZigBee chips
Flow batch integration? Real time data processing scenario application example~
Rip routing information protocol
Agvmir205 -- software development (API call)
从字符串中提取数字
HCIA学习思路
Mongodb complex query instance (nested multiple arrays and regular expressions)
AGVmir205--软件开发(API调用)
Great reward for data visualization chart plug-in development works (I)
C # from entry to mastery (II)
The image after the RGB and a channels are separated from the atlas, and the original image is exported after the RGBA channel is merged
Super detailed - working principle of NMOS and PMOS and related content sorting (Part 1)
Channel length modulation effect and short channel effect
MGRE experiment
Hcip day 8
Single arm routing configuration
MCU demand of smart meters and ranking of meter chip manufacturers
MySQL经典面试题 14 道
rip综合实验
探索式软件测试