-
如何添加斷言tests:tests右側(cè)已提供了一些實(shí)例代碼
pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("string_you_want_to_search");
});
pm.test("Response time is less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
- 響應(yīng)報文是json結(jié)構(gòu)的數(shù)據(jù)馁筐,value字段值是否等于100(驗(yàn)證json結(jié)構(gòu)值):
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.value).to.eql(100);
});