I want to make a Postman collection of requests hitting the same API endpoints as different users. For example:
- login "user_1"
- set data
- login "user_2"
- get data & check correct
I could make the login request a separate request, so the example above would be four separate requests. But for more complex situations that's a lot of login requests which is messy.
So I thought I would use a pre-request script to do the login. I could copy and paste the same login script into each pre-request script section. This is obviously not ideal as if I need to change something I'll have to change it for each request individually.
The other option is a collection level pre-request script. However there is no way to set the "user" variable to choose which user I want before running the collection pre-request script. The request level pre-request script runs after the collection level pre-request script. The only way I can see to set it before is to do it in the Test of the previous request, but that would be extremely fragile and require multiple changes should I wish to change the order of the tests.
Is there some other option I'm missing?
Aucun commentaire:
Enregistrer un commentaire