# Collection Runner doesn't mark the tests as failure when they fail

**URL:** <https://community.postman.com/t/collection-runner-doesnt-mark-the-tests-as-failure-when-they-fail/27797>\
**Category:** Help Hub\
**Created:** [September 13, 2021, 4:55pm UTC](https://community.postman.com/t/collection-runner-doesnt-mark-the-tests-as-failure-when-they-fail/27797 "2021-09-13T16:55:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![uguryiilmz](https://avatars.discourse-cdn.com/v4/letter/u/a587f6/32.png) [@uguryiilmz](https://community.postman.com/u/uguryiilmz)\
**Post date:** [September 13, 2021, 4:55pm UTC](https://community.postman.com/t/collection-runner-doesnt-mark-the-tests-as-failure-when-they-fail/27797/1 "2021-09-13T16:55:32Z")

</div>

Hello,

Thank you for the great work and helping community to grow . Postman has been pretty useful so far

I’m trying to test my endpoint by using collection runner and json data set. I am implementing new APIs and also have old APIs that supposed to return the same values, so i mainly check if the response from old-new endpoint are equal to each other. It works well except that it doesn’t mark my iterations as failure when they fail. For example; i am checking the length from two different endpoints as below

` pm.expect(new_endpoint.data).to.have.lengthOf(old_endpoint.length);`

and in the console i’m getting an error saying `AssertionError: expected [Array(57)] to have a length of 69 but got 57`. However the collection runner still marks this test as passed. You can see the screenshot (Iteration 5 errors out because the lengh doesn’t match but it is still showed as success. I don’t know if this is expected or a postman bug, just wanted to get an idea in case i’m doing something wrong.

 ![Screen Shot 2021-09-13 at 10.46.27 AM](https://us1.discourse-cdn.com/getpostman/original/2X/1/181eeb1810b938fe9658ab14a406bdb5311cac5c.png)

---

<div class="post-metadata">

**Author:** ![ianb120](https://avatars.discourse-cdn.com/v4/letter/i/f14d63/32.png) [@ianb120](https://community.postman.com/u/ianb120)\
**Post date:** [September 14, 2021, 7:26am UTC](https://community.postman.com/t/collection-runner-doesnt-mark-the-tests-as-failure-when-they-fail/27797/2 "2021-09-14T07:26:20Z")

</div>

Hi,

Just to check you are wrapping that assert in a pm.test function first of all and then using the assertion as a callback function in the test?

Otherwise it would lead to something like this, where the assert error shows but postman isn’t logging it. You’d need something like this.

```auto
pm.test("test description here...", function() {
    pm.expect(new_endpoint.data).to.have.lengthOf(old_endpoint.length);
}

```

---

<div class="post-metadata">

**Author:** ![uguryiilmz](https://avatars.discourse-cdn.com/v4/letter/u/a587f6/32.png) [@uguryiilmz](https://community.postman.com/u/uguryiilmz)\
**Post date:** [September 14, 2021, 2:31pm UTC](https://community.postman.com/t/collection-runner-doesnt-mark-the-tests-as-failure-when-they-fail/27797/3 "2021-09-14T14:31:44Z")

</div>

Hi Ian,

yeah it’s wrapped in the function. Here’s what i have. I wonder if it’s happening because i have another async request with sendRequest

```auto
pm.test(`response from two endpoint are equal to each other with ${media_types} media_type`, function () {
    let new_endpoint = pm.response.json();
    new_endpoint.data.sort((a, b) => {
        return moment(a.date).unix() - moment(b.date).unix()
    })    

    const headerRequest = {
        url:`url`,
        method: 'GET',
        header:{
                'token': token,
        }
    }

    pm.sendRequest(headerRequest, (error, response) => {
        const old_endpoint = response.json().data
        console.log("old endpoint",old_endpoint)
        pm.expect(new_endpoint.data).to.have.lengthOf(old_endpoint.length);

```
