# How I can skip tests when the first one is failed

**URL:** <https://community.postman.com/t/how-i-can-skip-tests-when-the-first-one-is-failed/37975>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [August 8, 2022, 9:45am UTC](https://community.postman.com/t/how-i-can-skip-tests-when-the-first-one-is-failed/37975 "2022-08-08T09:45:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![science-pilot-863855](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@science-pilot-863855](https://community.postman.com/u/science-pilot-863855)\
**Post date:** [August 8, 2022, 9:45am UTC](https://community.postman.com/t/how-i-can-skip-tests-when-the-first-one-is-failed/37975/1 "2022-08-08T09:45:11Z")

</div>

Hello, so hot topic.  
I saw a lot of similar Q&A around this theme.  
But still can not find the solution for my case:

I have a main, required test with a few expected results, and if one of them is failed → test is failed, the point is if the test is failed is not make sense to run others.

```auto
pm.test("Request is valid and has a body: " + pm.collectionVariables.get("exchange"), function () {
    pm.response.to.have.status(200);
    pm.response.to.be.json;
    pm.expect(data.length).to.gt(0);
});

```

Now I use such construction

```auto
let skipTest = data.length === 0;
(skipTest ? pm.test.skip : pm.test)("Each array item have required fields: " + pm.collectionVariables.get("exchange"), function () {

  data.forEach(function(item) {
      pm.expect(item).to.have.all.keys('base', 'quote', 'volume', 'price', 'volumePercent', 'spread', 'category', 'time');
  });
});

```

But in the **skipTest** part only one check

Is there any way to put in the variable skipTest a boolean value that the first test failed?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [August 18, 2022, 11:38am UTC](https://community.postman.com/t/how-i-can-skip-tests-when-the-first-one-is-failed/37975/2 "2022-08-18T11:38:37Z")

</div>

@science-pilot-863855

If your test fails on the status code, then the other assertions won’t run.

Your error message will be something along the lines of…

```auto
AssertionError: expected response to have status code 200 but got xyz

```

It will not mention the other assertions.

If you actually want all three assertions to run at all times, then you can wrap them in a try\catch.
