Reputation: 1
I would like to differentiate between 2 distinct tests within an if function in a flow.
This is my case: I have an endpoint returning a 400 and both of the following tests have failed:
pm.test("Response status code is 200", function () {
pm.response.to.have.status(200);
});
and
pm.test ("Response time is less than 200ms", () => {
pm.expect (pm. response. responseTime) .to.be.below(200);
});
However, I only care about the fact that the return was NOT a 200.
How should I put it in this workflow box?
Upvotes: 0
Views: 44
Reputation: 195
It's not too clear what you need but here's some info that migth be useful based on what I understand of your question:
You could use a single test with a conditional statement to check if the status code is not 200, it will pass if the status code is not 200 regardless of the actual value:
pm.test("Status code is not 200", function () {
pm.expect(pm.response.code).to.not.equal(200);
});
If you want to keep two separate tests, you could use a conditional (an if block) to only run the second test if the first test passes:
pm.test("Response status code is 200", function () {
pm.response.to.have.status(200);
});
if (pm.response.code === 200) {
pm.test("Response time is less than 200ms", () => {
pm.expect(pm.response.responseTime).to.be.below(200);
});
}
About how to put it in your workflow box, maybe this could help:
IF pm.response.code != 200 THEN
pm.test("Status code is not 200", function () {
pm.expect(pm.response.code).to.not.equal(200);
})
END IF
Upvotes: 0