What are some of the challenges you faced with JMeter?

If a subsequent request rely on the cookie set by the previous request, the "cookie manager" element is required.

When setting up the "CSV Data Set Config", don't have any spaces in the variable names

Have you used any features of JMeter that gave you greater flexibility?

A. Yes. The JMeter supports BeanShell scripting for greater flexibility. The BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java.

If you want to output all the order ids extracted out of the response messages for the response messages shown below



An XPath Extractor can be used to extract the "orderId" from the response message and store it in a variable named "orderId" as shown below.

Now, the BeanShell PostProcessor can use the extracted "orderId" variable and write to a file (e.g. C:\\Temp\\order-processing\id.txt ) as shown below.

You could do a lot more powerful things by writing your own embedded scripting with the BeanShell. For example, You can create your own file named MyBeanShell.bshr and copy it to $JMETER_HOME\bin folder. The MyBeanShell.bshr will have functions like


import java.text.SimpleDateFormat;

cal = Calendar.getInstance();
cal.add(Calendar.DATE, -10);
sdf = new SimpleDateFormat("dd-MMMM-yyyy");
return sdf.format(cal.getTime());


isTenth(int loopCounter)

returnValue = false;

if (loopCounter % 10 == 0)
returnValue = true;

return returnValue;


You could invoke these functions from your JMeter elements like

${__BeanShell(return getReportStartDate();)}

Also, note that pre-defined functions like __time can be used as shown above. There are also handy JMeter plugins from Google code at http://code.google.com/p/jmeter-plugins/ containing useful functions, listeners, samplers, etc. Just download the zip file and extract the "JMeterPlugins.jar" into $JMETER_HOME\lib\ext folder. This plugin features are prefixed with jp@gc.

 How do you ensure re-usability in your JMeter scripts?
Using config elements like "CSV Data Set Config", "User Defined Variables", etc for greater data reuse.
Modularizing shared tasks and invoking them via a "Module Controller".
Writing your own BeanShell functions, and reusing them.

No comments: