Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using value of user defined variable in another user defined variable in JMeter

Tags:

testing

jmeter

Is there any possibility to pass a value of user defined variable in another user defined variable? How to do this?


I've got a variable (name | value):

version | 5.6

and I want to use it in another one:

config | config_${version}.csv

enter image description here

It does not work because ${version} is treated as a string not as variable.

I've tried it with __eval function (the same) and with __P (then value of variable config was config1.csv, so ${version} was treated as a 1.


I'm using JMeter 3.3.

like image 935
faramka Avatar asked Jun 07 '18 11:06

faramka


1 Answers

Notice the warning in User Defined Variables:

the variables are not available for use until after the element has been processed, so you cannot reference variables that are defined in the same element. You can reference variables defined in earlier UDVs or on the Test Plan.

So you can declare version variable to Test Plan and call it using __V function in User Defined Variables:

   ${__V(config_${version}.csv)}

Another option is to move to User Parameters with similar usage of __V function

For defining variables during a test run, see User Parameters. UDVs are processed in the order they appear in the Plan, from top to bottom.

Note: __P is used for retrieving JMeter property and not variable

like image 192
user7294900 Avatar answered Oct 14 '22 07:10

user7294900