6
votes

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.

2

2 Answers

3
votes

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

0
votes

You can use jp@gc - Parameterized Controller for this.

Check the below snapshots

enter image description here

enter image description here

It;s up to you to use parameterized controller in place of UDV or combine them