当前位置:网站首页>Mock test using postman

Mock test using postman

2022-04-23 16:40:30 Sink the wine cup and fleeting time

Interface information

 Interface path 	/mock/testdemo

 Request header 
Content-Type	application/json
token	21232f297a57a5a743894a0e4a801fc3

 Request body 
{
    
  "memberid": "264903145",
  "phonenum": "17379797878",
  "msg": {
    
      "Country": " China ",
      "Province": " Guangdong province, ",
      "City": " guangzhou ",
      "Isp": " telecom "
  },
  "type_code": 0
}

 Response body 
{
    
    "code": "0000",
    "msg": {
    
        "result": "success",
        "memberinfo": " Silver members ",
        "membertype": "1"
    }
}

Create a new one Mock service

1、 open Postman, Click on the top left corner New, choice Mock Server

 Please add a picture description

2、 edit Mock Request information

 Please add a picture description

Choose here Create a new API, Create a new one Mock Of API Interface .

  • Method Select the corresponding request method
  • Request Path Fill in the interface path information ,
  • Request Body Fill in the request body information ( You need to check this option in the setting on the right )
  • Response Code Fill in the response code
  • Response Body Fill in the response body information

3、 To configure Mock Service information

 Please add a picture description

Fill in Mock Name of service ( Available in Chinese ), Check Make this Mock server private( Unchecked ), This Mock Services can only be accessed privately by yourself

 Please add a picture description

The yellow part is Mock Server address

If you need to do this Mock Service creation API key, You can click on the here Open a browser page , Need to generate a API key,

 Please add a picture description

name API key
 Please add a picture description

Generate secret key information

 Please add a picture description

When accessing this interface later , You must bring... In the request header API key, In order to visit successfully , It is equivalent to the role of an interface authentication

4、Mock Service creation succeeded

 Please add a picture description

You can also meet this need Mock The interface of , Edit the definition again , Click on Examples, To define template rules

 Please add a picture description

The request header specifies Content-Type The type of , add cookie / token Information , Specify the response returned json Information

 Please add a picture description

visit Mock service

have access to postman 、jmeter And other interface testing tools , It is still used here postman

In the address bar Mock The server address and interface path are spliced into URL, Fill in the corresponding parameters , Send a request

 Please add a picture description

You can find the content of the interface response , It's defined Examples The content in

版权声明
本文为[Sink the wine cup and fleeting time]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231402128189.html

随机推荐