Methods & Tools Software Development Magazine

Software Development Magazine - Project Management, Programming, Software Testing

Scrum Expert - Articles, tools, videos, news and other resources on Agile, Scrum and Kanban

Apache JMeter - Open Source Functional and Load Testing Tool

Sander Stevens, TechTest, http://www.techtest.nl/

Apache JMeter is open source software, a 100% pure Java desktop application, designed to load test functional behavior and measure performance of web sites. It was originally designed for load testing web applications but has since expanded to other test functions.

Web Site: https://jmeter.apache.org/index.html
Version Tested: jmeter 2.3.4 tested from October 2009 until February 2010
License & Pricing: Open Source
Support: User mailing list https://jmeter.apache.org/mail.html

What can I do with it?

Apache JMeter may be used to test functional and performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can also use it perform a functional test on websites, databases, LDAPs, webservices etc.

JMeter is not a browser. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc, but the timings are not included in any samples, and only one sample in one thread is ever viewed at a time).

Installation

The installation of JMeter (if you would call it an installation) is pretty straight forward. On the website is a link to the download area of stable versions. You also have the possibility to use nightly builds, but this is at your own risk. No guarantee that they work properly. So the advice is always to start with a stable version.

Download the latest version (zip or tgz) and unpack the archive to a local folder. Before starting JMeter it is wise to have a look at the configuration. The jmeter.properties file (located in the bin folder) contains a lot of settings. Most of those settings should be fine for the average user. The file is well documented and easy to read (and change where needed).

Also pay attention to needed additional jars. If you are going to use for example JDBC, JMS or JavaMail additional jars are not included in the JMeter installation. The user guide on the website explains how to use it and where to get it.

Starting JMeter is just a matter of double clicking jmeter.bat in the bin folder.

Documentation

There is an extensive documentation on the web site. In all kinds of ways. User manual, Wikis, docs and user experiences. The user manual describes how to create specific testplans (Web, Database, JMS, Webservice, etc) including step by step instructions, examples, bitmaps and tips. Also additional information is described in the user manual like best practices, information about regular expressions and how to use the variables and predefined functions. And last but not least: the component reference describes in detail how every component can be used.

The principle of JMeter

The principle of JMeter is very simple. If you want to test e.g. a SOAP interface layer, all you basically need is the URL and SOAP request. Starting with that you can build your test plan. And this can be as fancy as you want. Using variables, counters, parameters, CSV files, loops, logs, etc. There are almost no limits in designing your test and making it as maintainable as possible.

Apache JMeter - Open Source Functional and Load Testing Tool

Figure 1 - Snapshot of the JMeter interface

Let's assume you want to test a web server and fire off some http requests. Figure 1 shows a sample testplan. The testplan starts with some declarations for authorization and user defined variables. Also the JDBC connection is included. If a database is involved, you can set the database configuration and username/password. Don't forget to included the correct jars!

The HTTP request has some variables in its name. The name of the HTTP request will be displayed in the Result tree and therefore it is handy to include some kind of reference to the test you are running. In this example the testcase number, error description and error code is used to uniquely identify the request.

Figure 2 shows the detail pane of the HTTP request. You can add all the needed information like server name, portnumber, protocol (HTTPS is supported!) and parameters.

Apache JMeter - Open Source Functional and Load Testing Tool

Figure 2 - Adding an HTTP request to the testplan

With regular expressions you can extract for example session ids, store them in a variable and use them in following requests.

Reporting

For reporting purposes JMeter offers several possibilities. Most common is the View Results Tree. This tree will display the requests and has the ability to show the request and the response. The response can be displayed as text, XML, HTML or JSON. The component View Results Tree is mostly used for functional testing.

Apache JMeter - Open Source Functional and Load Testing Tool

Figure 3 - A snapshot of the View Results Tree

Performance testing needs a more advanced kind of logging with graphs and statistical data. The component Aggregate Graph is very useful. During the performance run you can monitor all kinds of statistical data like the # samples, average, median, 90% line and min / max. All this per request and total average. The data can be written to a file (plain text, csv or xml) and after formatting can be used to create a performance report.

You also have the possibility to view a graph of the statistical data. Select you column, enter the width, height and titles and click the Display Graph button. Of course is there again the possibility to save your graph or table data to a file.

Apache JMeter - Open Source Functional and Load Testing Tool

Figure 4 - Snapshot of the component Aggregate Graph

Conclusion

Need to test your web service, database, FTP- or web server? Both performance and functional testing? Have a look at Apache JMeter. It is free, very intuitive and has all the possibilities you need to automate your work. Another big advantage of JMeter: open source. You can download the source and make modifications to it if you like. Also direct contact with the developers through a mailing list is very handy.


More JMeter, Load Testing and Java Content


This article was originally published in the Spring 2010 issue of Methods & Tools

Click here to view the complete list of tools reviews

Methods & Tools
is supported by


Testmatick.com

Software Testing
Magazine


The Scrum Expert