How to stop Collection Runner on error?

I finally got it to work. :slight_smile: I had to set the nextrequest to null, then do my test. If my test fails the next line is not executed so it stops. But if it passes then I clear the null so the collection moves on. whew…

I also moved my variable setting up into the pm.test so they do not occur if the test fails.

pm.test("Status code is 200", function () {
    postman.setNextRequest(null);
    pm.response.to.have.status(200);
    postman.setNextRequest();
    //convert to json format
    var RespData = xml2Json(responseBody);
    //set environment level variable
    pm.environment.set("PolicyNumber", RespData['OnlineData.autoSaveDataRs']['$']['policyNumber']);
    //return policy number in test tab
    pm.test(pm.environment.get("PolicyNumber"));
});
8 Likes