# Is there any way to continue with tests in postman even if any one assert fails in it?

**URL:** <https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583>\
**Category:** Help Hub\
**Tags:** expect, result, responseassertion, pm, tests\
**Created:** [July 29, 2020, 12:20pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583 "2020-07-29T12:20:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [July 29, 2020, 12:20pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/1 "2020-07-29T12:20:32Z")

</div>

In a Postman GET request, I have used multiple assertions. However, if any assertion fails, Postman will stops its execution then and there and will throw an error.

Is there any way to prevent this and continue with other assertions even if any one among them fails?

pm.test(“Verify the Usage amount for Text”, function () {  
pm.response.to.have.status(200);  
var jsonData = pm.response.json() ;  
pm.expect(responseBody.length).to.eql(3);  
pm.expect(jsonData, “response is NOT empty”).not.to.be.empty;  
});  
like in above example, I wanted to test all 3 assertion and than fail the tests.  
Currently if it fails on first assertion, it stops the test and showed the result only for first assertion without testing rest two assertions.

---

<div class="post-metadata">

**Author:** ![kclausing](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kclausing/32/5133_2.png) [@kclausing](https://community.postman.com/u/kclausing)\
**Post date:** [August 4, 2020, 5:35pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/2 "2020-08-04T17:35:09Z")

</div>

try putting each validation in its own pm.test…

pm.test(“Verify the Usage amount for Text”, function () {  
pm.response.to.have.status(200);  
});

pm.test(“Verify the Usage amount for Text”, function () {  
var jsonData = pm.response.json() ;  
pm.expect(responseBody.length).to.eql(3);  
});

pm.test(“Verify the Usage amount for Text”, function () {  
pm.expect(jsonData, “response is NOT empty”).not.to.be.empty;  
});

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [September 3, 2020, 12:40pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/3 "2020-09-03T12:40:33Z")

</div>

Thanks for replying.Yes that is the one way, but I wanted to test all in one test command so that Total Test count will remain one in the report.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [January 28, 2022, 10:58pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/4 "2022-01-28T22:58:37Z")

</div>

If you run multi tests it fails like this with 1 output right? …

 ![trycatch2](https://us1.discourse-cdn.com/getpostman/original/2X/5/58b355a7ce84cd1bb4f19b3faa701868dd80cc17.png)

* * *

So then if you add try / catch statements like this example;

```auto
pm.test("API response contains the expected fields", () => {

const response = pm.response.json(); 

try{pm.expect(response).to.have.nested.property("category.name", "WRONG DATA");  
}catch(e){pm.test("A Test Failed", () => {throw new Error(e.message)});}

});

```

It will throw the error for each test that fails but continue through like so…

 ![trycatch3](https://us1.discourse-cdn.com/getpostman/original/2X/3/38a889a8f0f9caf33d6c5cb43f0f089b01e4ac48.png)

This is all within 1 pm.test so should display as 1 in the report as requested…  
Hope this helps

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [February 27, 2022, 11:59pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/5 "2022-02-27T23:59:50Z")

</div>

> [@w4dd325](#):
>
> ```auto
> pm.test("API response contains the expected fields", () => {
> 
> const response = pm.response.json(); 
> 
> try{pm.expect(response).to.have.nested.property("category.name", "WRONG DATA");  
> }catch(e){pm.test("A Test Failed", () => {throw new Error(e.message)});}
> 
> });
> 
> ```

Tests is always pass even assertion is failed. Is there any workaround for this??

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [February 28, 2022, 1:17pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/6 "2022-02-28T13:17:42Z")

</div>

Add this above the try catch

```auto
let count = 0;

```

And add this at the end of the try catch;

```auto
    if(count > 0) {
        pm.expect.fail("There are " + count + " failures within the above checks, please check...")
    } 

```

---

<div class="post-metadata">

**Author:** ![marcelsmit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/marcelsmit/32/11666_2.png) [@marcelsmit](https://community.postman.com/u/marcelsmit)\
**Post date:** [March 21, 2022, 2:35pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/7 "2022-03-21T14:35:43Z")

</div>

Hi,  
also looking for that solution, but where exactly? I tried it, and it doesn’t do a thing…

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [March 21, 2022, 10:13pm UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/8 "2022-03-21T22:13:06Z")

</div>

Hi @marcelsmit  
I’m not sure what you mean by “doesn’t do a thing” … could you please share what you have tried?

Here is a screenshot of my code above working;  
(Note; 2 of the try/catch statements are set to fail and then I use pm.expect.fail to fail the overall test)

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/1/1d504364e34e98b9fe6b66bd4eb8255e20a2cb24.png)

And here is a screenshot when the try/catch has the correct data;

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/f/f671a9142123ecc2750eaabc3ac2dae3623f6359.png)

---

<div class="post-metadata">

**Author:** ![marcelsmit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/marcelsmit/32/11666_2.png) [@marcelsmit](https://community.postman.com/u/marcelsmit)\
**Post date:** [March 22, 2022, 6:34am UTC](https://community.postman.com/t/is-there-any-way-to-continue-with-tests-in-postman-even-if-any-one-assert-fails-in-it/14583/9 "2022-03-22T06:34:13Z")

</div>

Sorry for my short question without further explanation.  
My point was that I used the try/catch in your example. and that didn’t do much. The earlier example of a year ago of course did well.  
But now that I see your screenshot I realize I forgot something to add.: )}), count++;} with every check
