In JMeter value of user.dir varaible is set to jmeter/bin directory. Jmeter saves and loads the test script from user.dir, so by default it is jmeter/bin. But what if your test scripts are saved in directory other than jmeter/bin which is the case most of the time.
We can override the value of this varaible in jmeter/bin/jmeter.properties as mentioned below:
user.dir=C:/perftest/mytest
Now the jmeter wil look for test script in C:/perftest/mytest instead of its default location. We can also specify this varaibale as jvm arg; if we are running jmeter from command prompt. (-Duser.dir=C:/perftest/mytest)
Accessing user.dir value in Jmeter test plan
In Test Plan -> User Defined Variables add a new variable
Name: userdir
Value: ${__property(user.dir)}
Now this userdir varaible can be used in jmeter test plan as location of the test script (${userdir}).
Reading values from a file
${__CSVRead(${userdir}/env.txt,0)} -> It will read the first column of the first line from the env.txt file
__P
This is a property function which is intended for use with properties defined on the command line. Unlike the __property function, there is no option to save the value in a variable, and if no default value is supplied, it is assumed to be 1.
${__P(request.threads)} -> return the value of request.threads
${__P(request.loop)} -> return the value of request.loops
${__javaScript(${__P(request.threads)}*2)} -> multiply the value of request.threads by 2
Wednesday, April 15, 2009
JMeter: Using Variables
Subscribe to:
Post Comments (Atom)
1 comment:
JMeter has also a lot of useful functions not only for working with variables and properties, but also for logging messages, running scripts and evaluating expressions. Little review about jmeter functions
Post a Comment