Trying to Skip one of my common tests placed in parent folder for only one request inside it

Hi, I am trying to Skip one of my common tests placed in the parent folder for only one child Request.
ex: Folder: Test Claims - contains below test
pm.test(“status to be 200”, function(){
pm.expect(pm.response.code).to.equal(200);
});
pm.test(“responsesize to be <200”, function(){
pm.expect(blabla).to.be.below(200);
});

II have 3 request under folder say
Req1
Req2
Req3
Since I placed tests in folder it will run for all 3 requests.
For Req2 i don’t want response size test to be executed.

Can anyone help me how I can do this, please???

Hey @saitejagoud080996,

If each request has a different URL you could put a condition in your Tests so they run only on the requests that are not that URL.
Example:

if (pm.request.url != "REQUEST_URL_TO_SKIP") {
    pm.test("status to be 200", function() {
        pm.expect(pm.response.code).to.equal(200);
    });
} 

While this does what you ask for, for scaling reasons if you’re planning to add more requests/tests I would recommend to write the tests in each requests instead of doing it at the folder level.

1 Like

Hi Arlemi,

Thanks for your response but my request URL is same for all requests and out of my 12 tests say only two of them are not applicable for common test, so likely scenario is to place in folder, also i cannot pull out those 2 tests out because all belong to same category - validations ::slight_smile:
can you please help if you have any other idea?

In that case you could use pm.info.requestName to do a condition on the name of the request, assuming these are unique?
For example if I have three requests named “a”, “b” and “c” respectively, the following code will skip b:

if (pm.info.requestName != "b") {
    pm.test("status to be 200", function() {
        pm.expect(pm.response.code).to.equal(200);
    });
}
1 Like

Hi arlemi,

yes, I have different names on each test case and you answer helped like 100%
Thanks a lot

1 Like