Problem: I want to set a counter variable (a numeric value) in environment variable, so in "Test" we can control the flow.
My experiment: I wrote a simple API call with following-
Prescript sets the counter variable-
postman.setEnvironmentVariable("mycounter", 1);
Test verifies the counter variable, if its value equals to 1, increment it by one-
if (postman.getEnvironmentVariable("mycounter") == 1 ) { postman.setEnvironmentVariable("result", "YES"); postman.setEnvironmentVariable("mycounter", 1+postman.getEnvironmentVariable("mycounter")); } else { postman.setEnvironmentVariable("result", "NO"); }
But when i check the value for "mycounter"-
- Actual value: 11
- Expected value: 2
Can anybody point out how to set numeric value in environment variable?