lundi 30 avril 2018

Postman testscript - check that the status is NOT 200

I'm creating a script to test my api, I want to check that if the user doesn't enter the correct username & password, the access is denied.

I want my test to get PASS when the status is 401. But postman give me a FAIL because the status of my request is not 200.

I actually WANT my response to be 401 in order to pass the test.

Any idea on how to operate ?

Cheers

I tried using :

pm.test("Status code is 401", function () { pm.response.to.have.status(401); });

this test pass, but Postman give me a FAIL assertion on top :

fail

response is ok | AssertionError: expected response to have status code 200 but got 401

Aucun commentaire:

Enregistrer un commentaire