- 如何添加斷言tests:tests右側(cè)已提供了一些實(shí)例代碼
image.png
- 響應(yīng)主體是否包含指定內(nèi)容:
pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("string_you_want_to_search");
});
- 響應(yīng)時間是否小于200ms:
pm.test("Response time is less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
- 響應(yīng)狀態(tài)碼是否等于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);
});