My JMeter project is like this.
project
|
----> test (folder containing .jmx)
|
----> properties (folder containing .properties files)
In the non-gui mode, I can pass .properties file name to the test via commandline - which I know.
But how can I read this property file in GUI mode while debugging? I do not want to place them in the bin folder. Is there any other way? like a config element? Is it easy to write a custom config element to read a property file?
The property files will be automatically loaded if they are found in the current directory or if they are found in the JMeter bin directory.
Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function. When using \ before a variable for a windows path for example C:\test\${test}, ensure you escape the \ otherwise JMeter will not interpret the variable, example: C:\\test\\${test}.
JSR223 Sampler JMeter Sampler elements allow taking actions in any place in the test, without depending on a specific request. In this example a JSR223 sampler will be used to send HTTP requests to either BlazeMeter or JMeter websites, based on the thread id.
1.1. Because JMeter uses only standard Java APIs, please do not file bug reports if your JRE fails to run JMeter because of JRE implementation issues. Although you can use a JRE, it is better to install a JDK as for recording of HTTPS, JMeter needs keytool utility from JDK.
I too had a same requirement. It is easy to write a config element.
Refer to this. http://www.testautomationguru.com/jmeter-property-file-reader-a-custom-config-element/
The simplest way is passing the property file location to JMeter running in GUI via -q
command-line argument as:
jmeter.bat -q d:\somefolder\somefile.properties
Alternative option is using scripting, i.e. you can read arbitrary .properties file via Beanshell Sampler and the following code:
FileInputStream is = new FileInputStream(new File("d:/somefolder/somefile.properties"));
props.load(is);
is.close();
You'll be able to reference properties loaded this way as normal using __property() or __P() function.
For more information on scripting in Apache JMeter and a kind of Beanshell cookbook see How to use BeanShell: JMeter's favorite built-in component guide.
Add "tag-jmeter-extn-1.1.jat" in ext of your jmeter. Then you can use Property file Reader easily
My THScript.properties looks like below
TH_Performance_ScriptName=Web.jmx Performance_TestData=c:/Result/
Accessing Property file values:
${__P(Performance_TestData)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With