بررسی status code دریافتی از سرور
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Status code is 200", function () { pm.expect(pm.response.code).to.equal(200); }); pm.test("Request is successful", function () { pm.response.to.be.succes; }); // Status code is in the 2XX range pm.test("Request results in a client error", function () { pm.response.to.be.clientError; }); // Status code is in the 4XX range pm.test("Request results in a Not Found error", function () { pm.response.to.be.notFound; }); // 404 pm.test("Status code is 200 or 204", function () { pm.expect([200, 204]).to.include(pm.response.code); });
بررسی هدرهای دریافتی از سرور
pm.test("Response has Content-Type header", function () { pm.response.to.have.header("Content-Type"); }); pm.test("Response has Content-Type header with application/json; charset = utf - 8 as value", function () { pm.response.to.have.header( 'Content-Type', 'application/json; charset=utf-8'); });
بررسی بدنهی درخواست
pm.test("Response has a non-empty body", function () { pm.expect(pm.response.text()).not.empty; }); pm.test("Response has a non-empty body", function () { pm.expect(pm.response.json()).not.empty; }); pm.test("Response has a non-empty body", function () { pm.response.to.have.body(); }); pm.test("Response has a non-empty body", function () { pm.response.to.have.jsonBody(); });
بررسی خواص اشیاء دریافتی از سرور
var updatedAuthor = pm.response.json(); pm.test("Author properties have been updated", function () { pm.expect(updatedAuthor.firstName).to.equal("Vahid"); pm.expect(updatedAuthor.lastName).to.equal("N"); });