I have a collection with requests. But I might have multiple requests with the same name, so I would like the ability to edit the request name from the "Tests" tab (perhaps by adding a sequence number to the beginning of the request name).
For example...
Test collection:
- Logon
- Clear All Subscribers
- Create Subscriber
- Create Subscriber
- Logout
Then I run the collection that then executes the code in the "Tests" tab. And now the collection looks like this...
Test collection:
- 1 Logon
- 2 Clear All Subscribers
- 3 Create Subscriber
- 4 Create Subscriber
- 5 Logout
Now one can differentiate between the two "Create Subscriber" requests because their request names are now "3 Create Subscriber" and "4 Create Subscriber".
I get that in this example it would be easy to just manually edit the request names. But in practice my collection will have 100's of requests so doing it manually is not viable.
I looked at the pm.info.requestName function but it's a read-only.
If you want to set dynamically the request name in the TFS report :
You will get something like that : PASS : "Your test name" + number incremented.
You need to set a counter in the collectionVariables with the initial value to 0.
collection variables
Then you can use the test tab of your collection to increment the counter. This incrementation will execute after each tests.
collection tests
After that, you can add some javascript on the test tab of your request See the result just under : Your tests is now "Your test name"+ incremention
test for each request
Finally don't forget to reset the counter in the last request of your collection
last request of the collection for the reset Watch at the screenshots I added for more details.
You can also use this counter into your console.log()
Hope it's help ! :)