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

Categories

0 votes
5.1k 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...