pm.test("response is ok", function () {
pm.response.to.have.status(200);
});
I would like to customize the text with a variable coming from a Data Input File:
pm.test("response FOR CUSTOMER " + {{path}} + " is ok", function () {
pm.response.to.have.status(200);
});
In Collection Runner I open an input file that populates the variable path.
This means the variable path is undefined at the start, it is populated at run time.
With the first Response Handling statement (without ‘path’ in the text, see top of my post) the execution is perfect, the variable path is read from the input file, populates the URL and executes as expected.
As soon as I try to include the variable “path” to leave information in the Response Handling statement text, I get an error and the variable is displayed as undefined (only in the text, the url is still working fine)
I cannot use
> pm.environment.get("path")
since “path” is not an environment variable, it is undefined at start populated first at run time
Have you tried accessing the variable in your script by using the “data” variable?
if you want to get the path to output, and path is a column in your data file, it looks like all you would need to do is data.path, so that your code would look like so:
pm.test("response FOR CUSTOMER " + data.path.toString() + " is ok", function () { pm.response.to.have.status(200); });
That’s strange - Was there a particular error message that was returned when you tried using this? Interesting to see where it’s failing for you.
The pm.iterationData function has been part of the app for a while now and is the best thing to use when working with data files loaded in from the Collection Runner.