postman use and assertions

// HTTP response status code asserted 200
tests["Status code is 200"] = responseCode.code === 200;
 
// assertion in response to the content contains "code": 9420
tests["Body matches string"] = responseBody.has('"code":9420');
 
// parse the response content and determine the value of the code is: 9420, the value of msg is: Congratulations qzcsbj, the login is successful
var jsonData = JSON.parse(responseBody);
tests["response statusCode"] = jsonData.code === 9420;
tests [ "response message"] = jsonData.msg === 'Congratulations qzcsbj, the login is successful ";
 
 
// assert response time is less than 200ms
tests["Response time is less than 200ms"] = responseTime < 200;

 

 

2. Request API to save history

 

Guess you like

Origin www.cnblogs.com/tsgxj/p/11634936.html