I am attempting to write tests in Postman for the first time. I am using the pm.test
method containing pm.expect
.
Here is my test:
//contract details tests
pm.test("Contract data is correct", function() {
pm.expect(pm.response.json().results.contractNb).to.equal("00002");
pm.expect(pm.response.json().results.progSrvcNm).to.equal("009");
});
My response appears like so:
{
"contractNb": "00002",
"progSrvcNm": "009",
"contractPartyNm": "testContract",
"terms": 30,
"startDt": "2018-01-01"
}
The correct code was as Danny Dainton posted.
pm.test('Contract details are correct for the passed in contract ID', () => {
pm.expect(pm.response.json().contractNb).to.equal("00002");
pm.expect(pm.response.json().progSrvcNm).to.equal("009");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.