Home > Mobile >  JMeter - saving properties in variables, but JMeter not resolving the variable
JMeter - saving properties in variables, but JMeter not resolving the variable

Time:05-09

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

enter image description here

With all steps disabled except one, no errors, and I get the vars in the output.

enter image description here

When I enable one step that uses a variable, the error is displayed.

enter image description here

And here is the CSV Data Config: enter image description here

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:

  1. Convert JSR223 PreProcessor to JSR223 Sampler
  2. Put it under setUp Thread Group
  • Related