dimanche 21 juin 2020

Retry failed postman/newman tests with multiple assertions

I'm trying to find a neat way to retry failed tests for my postman/newman calls. One of the tests is running a GET to check if all the data is returned correctly. Sometimes there are delays, so not all the tests pass at the first GET.

In other words, if I have a test like:

pm.test("All xx data is populated correctly", function () {

    pm.expect(dataGroup[0].someExtraDetail.value).to.eql(pm.variables.get("value1"));
    pm.expect(dataGroup[1].someExtraDetail.value).to.eql(pm.variables.get("value2"));
    pm.expect(dataGroup[2].someExtraDetail.value).to.eql(pm.variables.get("value3"));
    pm.expect(dataGroup[3].someExtraDetail.value).to.eql(pm.variables.get("value4"));
    pm.expect(dataGroup[4].someExtraDetail.value).to.eql(pm.variables.get("value5"));
    pm.expect(dataGroup[5].someExtraDetail.value).to.eql(pm.variables.get("value6"));

});

I would have to run the GET several times to see all the tests pass. I have multiple sections of data in my response and several tests like the one above to see if I eventually get all the expected data. I've been trying to think of a nice way to use postman.setNextRequest("The same GET"); in this situation to automate the tests, but still haven't found a good condition on which the request could be retried. Any ideas?

Aucun commentaire:

Enregistrer un commentaire