Archive for November, 2009

JMeter: Using property function to fetch data from user input

November 3, 2009 5 comments

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: ,