Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

How set a variable as a parameter value in JMeter

I'm trying to set a variable as a parameter value in a Backend Listener. I tried to add the variable as

${"testname"}

and also as

$["testname"]

but both options didn't work. JMeter consider them as a string and not as a variable. Any ideas how I can do that ?

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The correct syntax for JMeter Variables is ${variable_name_here} so you need to change it to ${testname} and it should start working as expected.

If there will still be problems make sure that the variable is defined and has its respective value, it can be done using Debug Sampler and View Results Tree listener combination

P.S. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting instead of Beanshell (and in fact any other languages) so while your script is relatively small maybe it's a good time for migration.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...