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?
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)}