how to run endpoint test with different variable values in Postman?

545 views Asked by At

This would seem to be a simple question, but not sure how to best set it up.

I have a few test cases for the same endpoint. I want to just pass different values for the various {{variables}}.

I know I can use pm.globals.set('..') and other ways to modify the env during testing, but I don’t want to basically code up my tests in JS, or use Newman. Also want to be able to easily share tests.

I’m assuming there must be somewhere in the UI (maybe test runner?) to say - run the same test and endpoint, but changing out these values, and expect different results. eg

/login
userId = “{{returningUser}}” => expect success
userId = “{{bannedUserId}}” => expect fail
userId = “{{unknownId}}” => expect fail

etc

Maybe I could script that up, but then I'd also have to use code to "call" the API to re-load the request. Seems like just writing jest tests in a clunky UI at that point.

1

There are 1 answers

0
Christian Baumann On

I see two possibilites for testing the same endpoint with different data:

  1. Either you use the collection runner with a data file, or
  2. You use the newman command line runner, using different environment files.

For sharing tests, you can either use Postman's integrated cloud stuff (never tried that), or export collections and environments and put them into a (git) repository. We're doing the latter. Yes, it's a bit cumbersome, but it works.