lundi 25 janvier 2021

Is it possible to have several pm.test() inside a pm.test()

Is it possible to have several pm.test() inside a pm.test()? In such a way that if any of the inner pm.test() fails, the outer pm.test() will also fail. And if no inner pm.test() fails, the outer pm.test() passes.

My requirement is similar to how pm.expect() works. But i want to use pm.test() instead so i can the status of each test in the Test Results tab.

My code is below.

var response = pm.response.json()
pm.test("Test scenario 1", ()=> {
    
    pm.test("Checking response code", ()=> {
        pm.expect(response.code).to.eql(200);
    });
    
    pm.test("Checking response message", ()=> {
        pm.expect(response.message).to.eql('OK');
    });
   
    //more pm test
});

Thanks a lot.

Aucun commentaire:

Enregistrer un commentaire