-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run Collection to use data files specified at Folder level #1529
Comments
@CharlieSnowCode Thanks for the feedback. Currently, it's not possible. I will review it. Alternatively, you can use scripting to read custom data files at the request level and set variable values. Could you please try the scripting option and let me know your feedback? |
I'll give it a try, could you help me get started? If each data file has 5 rows of values, how would I iterate through them? Where would the script be, in the PreRun Scripting or a custom filter file? If the file would be loaded by a custom filter, same question - how to iterate over the sets of values? |
var fileData = await tc.readFile("thunder-tests/test.csv");
var papaparse = require('papaparse');
var options = { delimiter: ',', quoteChar: '"', escapeChar: '"', header: true };
let csv = papaparse.parse(fileData, options).data;
console.log(csv);
var iteration = tc.info.currentIteration;
var iterationCsvData = csv[iteration];
if(iterationCsvData){
console.log(iterationCsvData);
var name = iterationCsvData["name"];
console.log("name", name);
// set variable using request scope so the value is not saved to active env file
tc.setVar("name", name, "request");
} sample csv file - test.csv
|
I've attached the (Pre run) script and the .csv I'm using, a snapshot of the (Restful Booker) Request and of the output. It seems like the script sees the file, but the Request is only executed once and none of the values are populated. |
Very interesting, I created a Collection and copied the script to it (I was using a folder inside an existing Collection which still doesn't work). Then increased the Iterations to 3 and it worked. Many thinks for your reply. |
For advanced use cases we recommend using scriping or cli is the best solution currently. |
Closing this issue as you can achieve the functionality using scripting |
I'm testing an API that has about a dozen unique Requests. I would like each of those Request types to be tested using their own data file, so I assume each would need its own folder. The Collection would have positive and negative cases and might look like:
Data Driven (Collection)
...
Setting different test data files at each folder is persisted, but when I Run All at the Collection level - none of the specified data files are used. Is there a way to do this? If not I would like to request it as a new feature. Thank you!
We are using the paid version.
The text was updated successfully, but these errors were encountered: