Build JMeter Test Plan
Atest plan can be visualized as your JMeter script for running tests. A test plan consists of test elements such as thread groups, logic controllers, sample-generating controllers, listeners, timers, assertions, and configuration elements.
There should be at least one thread group in every test plan. We can add or remove elements as per our requirement.
Let's start building a Test plan by following these simple steps:
Step 1: Launch the JMeter window.
- Go to your JMeter bin folder and double click on the ApacheJMeter.jar file to launch JMeter interface.
- The following image shows the default JMeter interface without any additional elements added to it:
- The default JMeter interface contains a Test Plan node where the real test plan is kept.
- The Test Plan node contains Name of the test plan and user defined variables.
- User defined variables provides flexibility when you have to repeat any value in several parts of the test plan.
Step 2: Add/Remove test plan elements.
- Once you have created a test plan for JMeter, the next step is to add and remove elements to JMeter test plan.
- Select the test plan node and right click on the selected item.
- Mouse hover on "Add" option, then elements list will be displayed.
- Mouse hover on desired list element, and select the desired option by clicking.
- The following image shows how to add a thread group element in a test plan:
- To remove an element, select the desired element.
- Right click on the element and choose the "Remove" option.
- The following image shows how to remove a thread group element in a test plan:
Step 3: Load and save test plan elements.
- To load elements to JMeter test plan tree, select and right click on any Tree Element on which you want to add the loaded element.
- Select "Merge" option.
- Choose the .jmxfile where you save the elements.
- Elements will be merged into the JMeter test plan tree.
- To save tree elements, right click on the element.
- Choose "Save Selection As" option.
- Save file on desired location.
Step 4: Configuring the tree elements.
Elements in the test plan can be configured by using controls present on JMeter?s right hand side frame. These controls allow you to configure the behaviour of the selected element. For example, a thread group can be configured by-
- Number of threads (the number of users you are testing).
- Ramp-up time (how much time you want to allow the Thread Group to go from 0 to 3 users).
- Loop count (How many times the test should be looped).
Step 5: Save JMeter test plan.
- Till now we are done with creating a test plan, adding an element and configuring a Tree.
- Now, you can save the entire test plan by choosing the "Save" or "Save Test Plan As" from file menu.
Step 6: Run JMeter test plan.
- You can run the test plan by clicking on the Start (Control + r) from the Run menu item or you can simply click the green play button.
- The following image shows how to run a test plan.
- When the test plan starts running, the JMeter interface shows a green circle at the right-hand end of the section just under the menubar.
- The numbers to the left of the green circle represents:
Number of active threads / Total number of threads
Step 7: Stop JMeter test plan.
- You can stop the test plan by using Stop (Control + '.') - It stops the threads immediately if possible.
- You can also use Shutdown (Control + ',') - It requests the threads to stop at the end of any on-going task.
Step 8:Check JMeter test plan execution logs.
- JMeter stores the test run details, warnings and errors to jmeter.log file.
- You can access JMeter logs by clicking on the exclamation sign present at the right-hand side of the section just under the menubar.
- The following image shows how you can access the JMeter logs: