Beginners Guide To Using The JMeter GUI Application

In this topic you will learn how to use the JMeter GUI application. You will learn how to add Elements to your test plan and how to run the Test Plan.

If you have already installed JMeter on your machine, you can follow along and practice the steps. Performing the exercise by yourself will increase your familiarity, confidence and knowledge of JMeter, compared to just reading the tutorial below.

We will be performing the below steps in this tutorial. How_to_create_test_plan_in_JMeter

Start JMeter

In order to start JMeter you need to browse to the JMeter directory. Run the jmeter.bat file to start the JMeter GUI.JMeter_Launch_start

JMeter application GUI will load as shown in the image below. You may also be able to start JMeter by double clicking the ApacheJMeter.jar file

JMeter_GUI_Main_application

JMeter adds a default Test Plan when it starts but it does not contain any additional elements in it.

There are 2 nodes in the left pane

  • Test Plan: This is where you add new elements.
  • WorkBench: This is a place to temporarily store test elements. Elements in the WorkBench are not saved when you save the Test Plan. In this topic we will focus on working with the Test Plan. We will look at how we can use the WorkBench in the topic on Recording a Session with HTTP Proxy in JMeter

Add a Thread Group

Now that you have an empty Test Plan, you can add any element in it. The common elements in JMeter are Thread Group, Assertion, Controller, Timers, Listeners etc.

In this case, we will add a Thread Group to the current Test Plan.

Right click on Test Plan > Add > Thread (Users) > Thread GroupJMeter_Add_Thread_Group_TestPlan

The Test Plan will now display the new Thread Group.

JMeter_Thread_Group_Settings

If you wish to remove any element from the Test Plan, you can select it, right click and choose Remove option or press the Delete key.JMeter_Remove_Thread_Group

Thread Group is the most basic elements in JMeter; you can add one or more Thread Groups to your Test Plan and name them as required. You will learn about the different element types in upcoming topics.JMeter_Multiple_Thread_Group

Adding and Removing Elements in JMeter

Once you have created Thread Group, you can add other JMeter elements such as Listeners, Logic Controller, Samplers etc.

In order to add an element to the Thread Group, select the Thread Group and right click on it. Choose Add, then choose the Element type (example Sampler) and then the Element (example HTTP Request).JMeter_how_to_add_elementsYou can add multiple element types to the Test Plan as per your projects requirement.JMeter_Add_Elements_listeners_Thread_Group

Configure Tree Elements

JMeter provides the controls to configure the Test Plan’s elements in the right frame of the application. Depending on the Element type selected, you will be able to configure the behavior of test element.

For example, In following figure, you can configure the Thread Group’s properties such as Name, Number of Threads (users), Loop Count, delay between threads etc

If there are multiple elements in your TestPlan, clicking on the desired Element will display its configuration details in the right hand pane.JMeter_Configure_Tree_Elements

Saving and Loading Elements in JMeter

Once you have created and configured the element, you can save it to file for future use. Let us assume that you have created a HTTP request element.

To save the element, right click the HTTP Request item and choose Save Selection As.JMeter_Save_Selection

Then save the element to disk by providing an appropriate name.JMeter_save-element-to-disk

As you can see, JMeter saves the element in .jmx file.

After saving the element, you can load it into other Test Plans.

To load elements from a saved file, right click the Thread Group and choose Merge.JMeter_merge_elements

Select the JMX file you created in previous step and click Open.JMeter_merge_elements_from_disk

The request you created will be merged into the test plan.Jmeter_element_in_tree

Running the Test Plan in JMeter

Before running a test plan, you should save it to your disk. JMeter will prompt you to save the plan if you have not saved it.

To save a Test Plan, right click the selected Test Plan and choose Save Selection As.JMeter_save_test_plan

Save the Test Plan to disk.JMeter_save_test_plan-2

Now run the Test Plan by click Start button from menu or use the keyboard shortcut Ctrl + R.JMeter_run_test_plan

The Test Plan starts to run.

When the Test Plan is running, the Stop button (red button with the text “Stop”) will be enabled as shown in the figure. During the test run, the Shutdown button will also be enabled (red button with the X symbol, next to the Stop button).JMeter_Stop_Test_Run

The other red button that you see in the above screenshot represent Remote Stop All and Remote Shutdown All. These are enabled during a remote execution.

On the far right of the toolbar you may also see the number of errors in the log (depending on the Elements you added to your Test Plan). The screenshot below shows that there are 6 errors.JMeter_Error_log_Active_Total_Thread

The green rectangle shows that JMeter is running. The numbers next to the rectangle represent the number of active threads and the total number of threads to run.

In the above screenshots 3 threads are active / running and there are 2 Thread Groups with 5 threads each which gives us a total of 10 threads.

You can open the log viewer by clicking on the yellow triangle with the exclamation.

The log will show you details of the error and other information that was logged (recorded) by JMeter. Sample output from the log is given below.

2016/04/07 13:38:51 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 
2016/04/07 13:38:51 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group. 
2016/04/07 13:38:51 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
2016/04/07 13:38:51 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false 
2016/04/07 13:38:51 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2016/04/07 13:38:51 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2016/04/07 13:38:51 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2016/04/07 13:38:51 INFO  - jmeter.services.FileServer: Stored:  
2016/04/07 13:38:51 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: Could not read file header line
	at org.apache.jmeter.services.FileServer.reserveFile(FileServer.java:284)
	at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:178)
	at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:408)
	at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:400)
	at org.apache.jmeter.control.GenericController.next(GenericController.java:162)
	at org.apache.jmeter.control.LoopController.next(LoopController.java:123)
	at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:88)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:259)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\apache-jmeter-2.13\bin\examples (Access is denied)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.(Unknown Source)
	at org.apache.jmeter.services.FileServer.createBufferedReader(FileServer.java:407)
	at org.apache.jmeter.services.FileServer.readLine(FileServer.java:333)
	at org.apache.jmeter.services.FileServer.readLine(FileServer.java:317)
	at org.apache.jmeter.services.FileServer.reserveFile(FileServer.java:281)
	... 8 more

2016/04/07 13:38:51 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1 
2016/04/07 13:38:51 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2016/04/07 13:38:51 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*)

While Test Plan is running, you can Stop or Shutdown the thread by clicking the Stop button on the toolbar or use shortcut key Ctrl + .

This example Test Plan will run even though we have not configured any of the elements. However, it will produce errors depending on the elements you have added to it and is not of any use in its current state.

In this topic we learnt how to work the JMeter application GUI and add various elements to a Test Plan, how to merge Test Plans etc.

In the next topic we will look at how to create Test Plan in JMeter that tests the performance of a website.