开发者

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开发者_JAVA技巧 want to declare a variable with the name propertyValue.

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


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜