Reference a variable within a variable in JMeter

Carlo picture Carlo · Apr 19, 2012 · Viewed 16.7k times · Source

I'm working with JMeter. I'd like to specify the test host using user defined variables, like this:

variable name       value  
localhost           localhost  
test                192.168.0.1
hostname            ${localhost}  

Executing the test, I see that the hostname value is not substituted, and obviously the test fails. I know I can use properties and pass the hostname from the command line, or simply change the hostname value. Is it possible to it like I've explained?
Thanks.

Answer

Carlo picture Carlo · Apr 19, 2012

I've managed to solve my problem. I've changed the hostname variable value to: ${__evalVar(${localhost})}, but I've got this error:

ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined

So I've moved the hostname variable declaration in a "User defined variable" child node of my Sampler node. That solved it.