JMeter - How to read properties file

前端 未结 3 967
Happy的楠姐
Happy的楠姐 2020-12-17 20:51

My JMeter project is like this.

project
    |
     ----> test (folder containing .jmx)
    |
     ----> properties (folder containing .properties files         


        
相关标签:
3条回答
  • 2020-12-17 21:29

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

    0 讨论(0)
  • 2020-12-17 21:34

    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/

    0 讨论(0)
  • 2020-12-17 21:46

    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.

    0 讨论(0)
提交回复
热议问题