mardi 5 décembre 2017

Postman testing nested requests

I am trying to write some postman tests for my API. In one of the requests I get a list of objects, each containing an ID. Currently my tests are assuring that the ID is there. But I would like check that a different request(using the ID) is working.

So how would I go about doing this? The key point is that I also want to check all objects in the list.

currently my test looks like this:

var detailValidator = function(err, res) {
    console.log("validating response from details");
    pm.expect(err).equal(undefined);
};

pm.test("All shows have working detail pages", function()
{
    var data = pm.response.json();
    console.log("Testing detail pages");
    for(var index in data) {
        //console.log("Testing details of " + data[index].showId);
        var requestURL = environment.url + "/services/6/countries/" + environment.country + "/cities/" + environment.city + "/shows/" + data[index].showId + "?theatremainaccount=0";
        pm.sendRequest(requestURL, detailValidator);
        console.log("sent request to:" + requestURL);
    }
});

But no matter what I put in detailValidator it always passes, so what am I doing wrong here?

Aucun commentaire:

Enregistrer un commentaire