Mark a script as a failure

Hi,

I am new to postman, so please forgive me if I’m asking a dumb question.

I have a postman request.
It runs.
I have stuff in the request test section where I have coded several tests.
If any of these tests fail, I get an assertion error reported at the end.
However, the request itself is not marked as a failure.

How do I cause a request to be marked as a failure?
I not talking about another assertion failure, but a request failure.

The following test is being run thru newman.
As you can see I have two assertion errors.
But the request is still marked as a success.

If this isn’t possible; I won’t like it, but I will have an answer.

Thanks


| | executed | failed |
--------------------------±----------------------±-----------------------
| iterations | 1 | 0 |
--------------------------±----------------------±-----------------------
| requests | 2 | 0 |
--------------------------±----------------------±-----------------------
| test-scripts | 4 | 0 |
--------------------------±----------------------±-----------------------
| prerequest-scripts | 4 | 0 |
--------------------------±----------------------±-----------------------
| assertions | 2 | 0 |

total run duration: 4m 0.9s
total data received: 477B (approx)

average response time: 2m 0.3s [min: 5.3s, max: 3m 55.3s, s.d.: 1m 55s]

Hi @dmhunter – there is no such thing as a dumb question here!

Maybe adding in an assertion for the status code would help?

Hey @dmhunter,

A request failure indicates a connection-level failure (likely on the TCP, DNS, or TLS level).

If you want custom reporting to show the entire request as a failure if all its assertions fail, you can either build a custom reporter or see if a community-supported reporter exists already. Here are a few, but more can be found on npmjs.com: https://github.com/postmanlabs/newman#community-maintained-reporters

I agree with Hannah.Neil. You can add a check such as this, it checks the status response from the api call.

pm.test(“Status code is 201”, function () {

pm.response.to.have.status(201);

});