Home > jmeter > JMeter: Using property function to fetch data from user input

JMeter: Using property function to fetch data from user input

If our objective is to run our test scripts from the command line with variable number of users and ramp up period without editing our test plan every now and then, we could do this using JMeter’s simplified property function(“__P”).

First we need to set our Thread Group property as follows:

Thread group properties

Thread group thread and ramp-up properties

That is changing the value of Threads and Ramp-up as:

Threads: ${__P(group1.threads)}

Ramp-up: ${__P(group1.ramp)}

We could also use the property function when saving our test results. ${__property(result_dir)}/graph.jtl

Graph test result

Save graph result to a file

From the above settings, Jmeter will automatically generate a graph.jtl file inside result_dir folder.

Notice that number of threads, ramp-up period, result filename are all set as parameters.

After adding samplers and listeners to our testplan. We run our test from the command line by invoking:

jmeter -n -t test.jmx -Jgroup1.threads=10 -Jgroup1.ramp=5

From here onwards we could set different number of threads and ramp up period depending on the scenarios we’d like to test. Cool huh!

Categories: jmeter Tags: ,
  1. Bernard
    March 19, 2010 at 9:24 am

    Nice one Girlie!
    I like the command-line series!

  2. December 3, 2010 at 3:40 am

    nice job
    I was searching this.
    Thanks keep it up
    Please post some more interesting things on jmeter

  3. triendovan
    October 10, 2013 at 12:52 pm

    Hi Girlie!
    Error appear on command line :

    C:\Documents and Settings\Desktop\apache-jmeter-2.9\bin>jmeter -n
    -t test.jmx -Jgroupl.threads=10 -Jgroupl.ramp=5
    Created the tree successfully using test.jmx
    Error in NonGUIDriver java.lang.RuntimeException: Could not find the TestPlan class!

  4. September 17, 2014 at 8:45 pm

    Passing data via command-line arguments is not the only way of feeding properties to JMeter. See Apache JMeter Properties Customization Guide for more options.

  1. February 26, 2014 at 12:48 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: