I am writing a new API and want to be able to see how it fairs when hit with n requests.
I have tried to setup environment variables and use the runner tool within Postman to no avail.
End goal is to run it n times, where I pass in the value of [n] into the body so I can audit (the value of that field is stored in database).
I have setup 2 environment variables
company=Bulk API Test
requestcount=0
My pre-request script is
let requestCount = +postman.getEnvironmentVariable("requestcount");
if(!requestCount)
{
requestCount = 0;
}
requestCount++;
postman.setEnvironmentVariable("requestcount", requestCount);
Which should update the environment variable requestcount to +1 each time.
My test script is
var currentCount = +postman.getEnvironmentVariable("requestcount");
if(currentCount < 5) // want it to run 5 times
{
postman.setNextRequest("https://snipped");
}
else
{
postman.setNextRequest(null);
}
When I run it through the runner it takes much longer than a non-runner execution and the result is the API was only hit once.