mercredi 14 août 2019

Looping Requests in Postman (using POST Requests)

I have a data file with over 10,000 requests and I need it to loop through each test.

Example of text file:

text1~text2~text3
text1~text2~text3
etc.

My test script is:

pm.test("Status code is 200", function ()
    {
        pm.response.to.have.status(200);
    }
);

if ((pm.response.json()[0].ResultCode)===-1)
{
    pm.test("ResultCode -1 Matched!", function ()
    { 
        pm.expect(pm.response.json()[0].ResultCode).to.equal(-1);
    });
}

if ((pm.response.json()[0].ResultCode)===-5)
{
    pm.test("ResultCode -5 Matched!", function ()
    { 
        pm.expect(pm.response.json()[0].ResultCode).to.equal(-5);
    });
}

So the first test works and the second test works, but it stops testing furthermore.

The is my output of the tests tab:

Postman Result

Aucun commentaire:

Enregistrer un commentaire