Multiple test values

Hi there,

I’m really new to Postman and have what might be an obvious question!

What I’m trying to do is have an API spec file which has the specifications and the tests all in one - which Postman seems to be able to do - and then run the tests automatically - which may end up me doing something with newman.

In the tests, what I’d like to be able to do is have it try an end point without a particular value being completed, check it returns a 404, another parameter being null, check it’s a 404, try with one or all completed, check the response, etc. So say I have the endpoint ‘/comment?application_id={{application_id}}&account_id={{account_id}}&scope={{scope}}’, try it first with everything being empty, then with {{application_id}} having some content, then {{account_id}}, etc. {{scope}} is optional so would need to test that, too.

Now, if I understand it right I can use these variables and define them in my environment, right? But if I define them there won’t they always be filled out?

I can see that I can write tests in js which looks really neat as I’ll be able to tests response codes, values, etc. So I assume I can put the multiple tests mentioned above in there?

Thanks for any advice!

Andy

Hi @acollington
I just create separate reuqests that test a specific scenario, even when it’s all hitting the same request.
See below for some password related tests for our User Service:

image

The reason I have them like this is because our tests are ran in our CI (Team City) and it’s not just me that will be viewing the test results (even though I’m the one that writes/maintains the tests)

If regression has occured or one of these scenarios has failed, I want it to be clear to other people in the IT team which scenario has failed and what parameter was passed.

In the above scenarios, I’m mentioning that I’m attempting to use the autneticate user API endpoint after successfully changing the user’s password. But I’m also stating what status code I’m expecting in brackets and what parameter I’m passing (Original Password, Latest password) and whether they should be valid/invalid.

I’m sure you could do this with one request and changing the expected outcome each iteration and the passed parameter.

1 Like