1

I try to load values from properties file using simple JSR 223 Sampler using BeanShell which I do successfully simple like this :

for (String key : localConfigProp.stringPropertyNames()) {
                String value = localConfigProp.getProperty(key);
                props.put(key,value); 
} 

now i have UDV controller which i try to load from property to variable

test_param  ${__property(test_param,,${test_param_default} )}   

the UDV controller in after the JSR223 Sampler the problem is that in windows the test_param do set its value from the property file and in linux
the test_param still holds its default ${test_param_default} value
i guess it got something to do with this that the UDV controller is invoked first.

how can I make the script invoked before the UDV?

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
user63898
  • 29,839
  • 85
  • 272
  • 514

1 Answers1

1

You can't make the script invoked before the UDV.

The User Defined Variables element lets you define an initial set of variables, just as in the Test Plan.

Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.

You can either replace UDV with User Parameters Pre Processor

For defining variables during a test run, see User Parameters

Or update variable in JSR223 Element using vars:

vars - (JMeterVariables) - gives read/write access to variables:

vars.put("variableName", "newValue");

Variable will be updated in next steps when it will be used (not in UDV) as ${variableName}

EDIT

If you want to copy property to variable - you can add in value ${__P(START.HMS)}.

For JSR223 element you can use

vars.put("variableName", props.get("START.HMS"));
Community
  • 1
  • 1
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • User Parameters accepts variables ? i can use the __P helper ? – user63898 Apr 04 '18 at 08:52
  • @user63898 you want to copy property to variable? you can add in value `${__P(START.HMS)}`. for JSR223 you can use `vars.put("a", props.get("START.HMS"));` – Ori Marko Apr 04 '18 at 10:21
  • i want define the test plan variables in UDV or any other GUI controller I dont what to set the user variables in script . i tried User properties controller but it force me to do it in each Thread group can't i set it once in setUP group ? – user63898 Apr 04 '18 at 11:48
  • No, see https://stackoverflow.com/questions/707832/how-do-i-pass-a-variable-from-one-thread-group-to-another-in-jmeter but you can Add `Test Fragement` and reuse it in multiple thread groups. – Ori Marko Apr 04 '18 at 11:51
  • amazing such simple task but so complex to implement – user63898 Apr 04 '18 at 11:53
  • UDV is a pain in the... JMeter – Ori Marko Apr 04 '18 at 11:53
  • In general for dynamic/multi thread group parameters you should work with JMeter properties – Ori Marko Apr 04 '18 at 11:57