I'm using the JMeter Property file reader successfully to get values from a file.
Then I use a simple Groovy snippet to save those values in variables.
Why, then, is JMeter still thinking the variable is not defined?
Output to the console shows that the variables are being stored.
for (i in props)
if (i.key.startsWith('testData')) {
vars.put(i.key, i.value)
log.info(vars.get(i.key))
}
tigapo.prop:
testData.getUserHistoryPageUsingGETFile=HistoryControllerApi.csv
testData.createBillingUsingPOSTFile=BillingControllerApi.csv
testData.getCreditExchangeInfoUsingGETFile=BillingControllerApi.csv
testData.handleTagDetectionUsingPOSTFile=TagDetectionControllerApi.csv
testData.getSettingsUsingGETFile=SettingsControllerApi.csv
testData.createUserUsingPOSTFile=UserControllerApi.csv
With all steps disabled except one, no errors, and I get the vars in the output.
When I enable one step that uses a variable, the error is displayed.
And here is the CSV Data Config:
CodePudding user response:
Because CSV Data Set Config is being initialized before JSR223 PreProcessor, take a look at JMeter test elements execution order:
0. Configuration elements
1. Pre-Processors
2. Timers
3. Sampler
4. Post-Processors (unless SampleResult is null)
5. Assertions (unless SampleResult is null)
6. Listeners (unless SampleResult is null)
CSV Data Set Config is a configuration element hence it's being run before anything else.
so you need to:
- Convert JSR223 PreProcessor to JSR223 Sampler
- Put it under setUp Thread Group