Nikolay
Nikolay

Reputation: 83

Declare Jmeter variable from a property value

How can I declare a variable name by using the value of a property?

For example, I have the property propertyName with the value propertyValue. I want to declare a variable with the name propertyValue.

I've tried like ${${__P(variableName)}} but such constructions doesnt work.

Upvotes: 5

Views: 19066

Answers (3)

vins
vins

Reputation: 15400

Property files are great!!! For my requirement, I have created a simple config element for JMeter to read property files.

Please check here.

http://www.testautomationguru.com/jmeter-property-file-reader-a-custom-config-element.

Upvotes: 1

BlackGaff
BlackGaff

Reputation: 7707

You may need to evaluate the property name, using the ${__V()} function.

Thus, you'd probably end up with something like ${__V(${__P(propertyName)})} which would only declare a variable with a null value.

Basics on properties & command line:

if you need to pass variables through the command line, properties are indeed the correct choice.

The flag to set a property is -JpropertyName The function to read a property is ${__P(propertyName)}

For full details, see:

http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#How_do_I_pass_parameters_into_my_Test_scripts.3F_I_want_to_be_able_to_use_the_same_script_to_test_with_different_numbers_of_threads_and_loops.2C_and_I_don.27t_want_to_have_to_change_the_script_each_time.

Upvotes: 10

Andrey Pokhilko
Andrey Pokhilko

Reputation: 2668

Give up using properties files, try using Variables From CSV plugin. It is pretty simple and robust way to have variables loaded from file.

Upvotes: 1

Related Questions