Thursday, January 28, 2010

Tip #4: Using JMeter properties

Sometimes I need to modify some parameters in the Test Plan and it requires me to start JMeter, open the Test Plan file and edit these parameters there. But it's better to use JMeter properties for this task. Look at the image below.



There are JMeter properties used as values of "Number of Threads (users)" and "Loop Count" options: ${__P(users)} and ${__P(count)}. Also we must add two parameters to JMeter command line:

jmeter -t TestPlan.jmx -Jusers=10 -Jcount=50

Now you can specify necessary parameters on the fly. I recommend you to use properties for the following options: number of users, loop count, host, port, results and data filenames, etc.

17 comments:

  1. We're new to jmeter and this is an eye-opener in terms of being able to automate it; thanks for this post!

    ReplyDelete
  2. Awesome Really ! ...Saurabh

    ReplyDelete
  3. Very helpful..Thanks

    ReplyDelete
  4. Hi very help full but how can I replace the endless bucle? Thanks

    ReplyDelete
  5. Thank you, was wasting time trying to set a variable from the command line.

    ReplyDelete
  6. Surprised me greatly... useful tip

    ReplyDelete
  7. Does this work in non-GUI mode, meaning when i start JMeter with jmeter-n.cmd?

    ReplyDelete
  8. Is there a way to set as a property file? Thanks

    ReplyDelete
    Replies
    1. You can specify any value as a property, i.e. integer number, floating-poing number, string, etc. There are no limitations.

      Delete
  9. Hi Victor,
    I have a question, can I re-read the value in properties file without restarting jmeter? For example, I have started jmeter by the command 'jmeter -nt sms.jmx -p sms.properties', but I want to change the value in the property file when jmeter is still running. Can jmeter read the new value without being restarted? Thank you in advance.

    BR
    /Lisa

    ReplyDelete
    Replies
    1. I'm not sure that this is possible. You can try to use __setProperty function for changing the property value at runtime.

      Delete
  10. Hi Victor,

    I have provide
    Number of Threads(users) - ${__P(users)}
    Ramp-up Period(in seconds) - 1
    Loop Count: Forever

    and did Scheduler Configuration where my Start time and Start date were past and provide the duration as 300.

    I expect my request to run for 300 seconds and to generate 300 requests. But it generated only one request.

    Now as option2 i have proivded my loopcount as 300 but stil only one request was run.

    As a last option i wanted my threads to run for 300 seconds, so i have set
    Number of Threads(users) - 1
    Ramp-up Period(in seconds) - 1
    Loop Count: 300

    I expect 300 requests should run for 300 seconds, but they got run in just 3 to 4 seconds.

    Any help

    ReplyDelete
    Replies
    1. Number of Threads(users) - 300
      Ramp-up Period(in seconds) - 1
      Loop Count: 1

      Does it make sense?

      Delete
  11. Thank you very much! This is very helpful!!!

    ReplyDelete
  12. This is what I was looking for. Thanks dude.

    ReplyDelete