Home > other >  With the postman verify whether interface returns a field
With the postman verify whether interface returns a field

Time:09-21

Interface returns:
{
"Data" : [
{
"Word", "Shanghai",
"A List" : [
{
"Word" : "attraction",
"Type" : "sight"
},
{
"Word" : "hotels,"
"Type" : "the hotel"
}
],
},
}
Need to verify the interface List whether return type field (do not need to verify the value is correct, as long as verify whether to return to the fields)


Tests of the script:
Var jsonData=(https://bbs.csdn.net/topics/pm.response.json);

PM. The test (" type field inspection ", function () {
Length=jsonData. Data [0]. List the length;
console.log(length);
for(i=0; IThe console. The log (jsonData. Data [0]. The List [I]);
PM. Expect (jsonData. Data [0]. The List [I]). To. Include (" type ");
}
});

Execution after an error:


There are a great god knew where the script is wrong?

CodePudding user response:

Have any questions can be added to the software testing technology group: 695458161 has a lot of enthusiastic test bosses to help you solve!

CodePudding user response:

Can use the postman tool that existing template, interface on the right side in the tests, find out there is equal, in, etc., click automatically fill in to write a script, you can change a little bit about the assertion content
  • Related