Hello,
Im calling postman collection LOCALLY through newman and it cant update new values for environment variables. My code is below:
var sum = 250;
var totalPaidAmount = Number(pm.collectionVariables.get("ContractPaidAmount"));
var sumOfContractTotalPaidAmount = totalPaidAmount + sum;
pm.environment.set("ContractPaidAmount",sumOfContractTotalPaidAmount);
pm.collectionVariables.set("ContractPaidAmount",sumOfContractTotalPaidAmount);
whether it is possible at all to do these things in newman?
Already integrated postman tests through newman in Azure CI/CD and thought that impossible to newman modify file values without my manual interaction…
Using the same logic you shared above, I ran the following test collection in Newman with a pre-req script that updated my environment’s file and it appears to work.
Here is what I did;
Generated a random number between 1 and 36 and used the environment.set to save the variable.
Then set the variable where I needed the random number to be fed in.
Then ran it in Newman, with the -e option for including my environments file. It ran for 5 iterations and as you can see the page number changes for each.
Hello,
thanks for the advice, I have fixed it. It works only in the current session, current environment variable values updates in the current session. Example:
But if i run tests in another time, all variables has last EXPORTED collection values and it loads i guess initial environment variables values. How can i update initial environment values? My variables should keep information from the last run.