jMeter - Build Test Plan


What is a Test Plan?

A Test Plan defines and provides a layout of how and what to test. For example the web application as well as the client server application. It can be viewed as a container for running tests. A complete test plan will consist of one or more elements such as thread groups, logic controllers, sample-generating controllers, listeners, timers, assertions, and configuration elements. A test plan must have at least one thread group. We shall discuss these elements in detail in the next chapter Test Plan Elements.

Follow the below steps to write a test plan:

Start the JMeter window

Open the JMeter window by clicking on /home/manisha/apache-jmeter-2.9/bin/ The JMeter window will appear as below:

JMeter GUI This is a JMeter window having nothing added yet. Details of the above window are:
  • Test Plan node is where the real test plan is kept.

  • Workbench node simply provides a place to temporarily store test elements while not in use, for copy/paste purposes. When you save your test plan, WorkBench items are not saved with it.

Add/Remove Elements

Elements (which will be discussed in the next chapter Test Plan Elements) of a test plan can be added by right clicking on the Test Plan node and choosing a new element from the "add" list.

Alternatively, elements can be loaded from file and added by choosing the "merge" or "open" option.

For example let's add a Thread Group element to a Test Plan as shown below:

Add Thread Group

To remove an element, make sure the element is selected, right-click on the element, and choose the "remove" option.

Remove Element

Loading and Saving Elements

To load an element from file, right click on the existing tree element to which you want to add the loaded element, and select the "merge" option. Choose the file where your elements are saved. JMeter will merge the elements into the tree.

Load Element

To save tree elements, right click on an element and choose the Save Selection As ... option. JMeter will save the element selected, plus all child elements beneath it. By default JMeter doesn't save the elements, you need to explicitly save it as mentioned earlier.

Configuring Tree Elements

Any element in the Test Plan can be configured in the controls present in JMeter's right-hand frame. These controls allow you to configure the behavior of that particular test element. For example the Thread Group can be configured for number of users, ramp up period etc as below:

Add Thread Group

Saving the Test Plan

You can save an entire Test Plan either by using Save or "Save Test Plan As ..." from the File menu.

Save Test Plan

Running a Test Plan

You can run your Test Plan choosing Start (Control + r) from the Run menu item. When JMeter is running, it shows a small green box at the right hand end of the section just under the menu bar.

Run Test Plan

The numbers to the left of the green box are the number of active threads / total number of threads. These only apply to a locally run test; they do not include any threads started on remote systems when using client-server mode.

Stopping a Test

You can stop your test in two ways:

  • Using Stop (Control + '.'). This stops the threads immediately if possible.

  • Using Shutdown (Control + ','). This requests the threads to stop at the end of any current work.