Interface test automation -Mock Get and Post requests

Mock background can simulate a http interface response can be simulated request, response 

下载 moco-runner-0.11.0-standalone.jar

Download Link: https://pan.baidu.com/s/1bmFzvJPRnDlQ-cmuJ_3iRg extraction code: kpjv

Be sure to install jdk, under cmd can run java -version

A simulated get request with no parameters

line # description code may not be written; general structure description, request, response, except description, other values ​​are in the form of key-value pair; define Request URI (interface address), Method (request mode), Queries or Forms;

Reference Code: 

[
{
"description":"this is a no param get",
"request":{
"uri":"/get",
"method":"Get"
},
"response":{
"text":"Yeah,you sucess"
}

}
]

 

 Two, get an analog band request parameter;

Parameters used "queries"

 

 Third, the transmission Post without parameters;

post request can not be accessed using a browser, you can use Postman or Jmeter tool;

 

 Browser to access the following results:

 

 Postman and provided the following results:

 

 

 

 

Jmeter and provided the following results:

 

 四、发送带参数的Post请求;参数使用"forms"

 

 Postman设置及结果如下图;键值(key,value)都传对了,status才显示200,否则显示400;

 

 jmeter设置及结果如下图;

Guess you like

Origin www.cnblogs.com/canglongdao/p/12174046.html