Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Test Plan in JMeter
2.1.
Thread Group
2.2.
Controllers
2.3.
Listeners
2.4.
Timer
2.5.
Assertions
2.6.
Configuration Elements
3.
Create a Test Plan in JMeter.
4.
Frequently Asked Questions
4.1.
JMeter is based on which programming language?
4.2.
What is the functionality of JMeter?
4.3.
Can we do functional or regression testing in JMeter?
4.4.
Can we create a test plan without any thread group?
4.5.
Can we set a time interval between thread requests?
5.
Conclusion
Last Updated: Mar 27, 2024

What is JMeter - Test Plan, and How to Write a Test Plan?

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

This blog will discuss the test plan in JMeter and how we can write a test plan in Jmeter step by step. JMeter is an open-source testing software developed by Apache based on pure java programming. JMeter is used to measure and observe the performance, functional, and load testing of web applications created in java.

The test plan is a part of the Jmeter, and we will learn how to create a test plan in JMeter to perform the relevant testing for our application.

Test Plan, and how to write a test plan?

Test Plan in JMeter

A test plan in JMeter is a container with pre-defined instructions that the JMeter will follow to perform the testing. The instructions contain what test to perform and how to perform it. There are a few test plan elements or attributes that we need to initialize when creating a test plan, such as thread groups, logic controllers, sample-generating controllers, listeners, timers, assertions, and configuration elements. You must include at least one thread group in the test plan in JMeter.

Let's get to know about the test plan elements in JMeter.

test plan elements

Thread Group

As the name implies, a thread group is a group of threads in a test plan. We can create or control the number of threads to carry out our testing. The Thread Group is also the beginning mark of the test plan.

Controllers

There are two types of controllers available in JMeter.

  1. Sampler - with a sampler you can send a request to a particular server. For example, you can send an HTTP request with the help of a sampler in the test plan in JMeter. Following are the types of requests you send.
  • HTTP Request
  • FTP Request
  • JDBC Request
  • Java Request
  • SOAP/XML Request
  • RPC Requests


2. Logic controller - With a logic controller's help, you can add a conditional statement or looping statements into a thread. You can add the following logic controllers in JMeter.

  • Simple Controller
  • Loop Controller
  • Once Only Controller
  • Interleave Controller
  • Random Controller
  • Random Order Controller
  • Throughput Controller
  • Runtime Controller
  • If Controller
  • While Controller
  • Switch Controller
  • ForEach Controller
  • Module Controller
  • Include Controller
  • Transaction Controller
  • Recording Controller

Listeners

With Listeners, you can display the output of Samplers as tables, graphs, trees, or plain text. As a JMeter Sampler component is run, they give graphical access to the information about the test cases JMeter has collected.

Timer

With Timer, you can add some intervals between the request you are sending with the help of the timer element in the test plan in JMeter.

Assertions

You can use assertions to add some validation checks to the answer to a request you performed using a Sampler. Assertions let you to demonstrate that your application is producing accurate data. 

Configuration Elements

You can create defaults and variables for Samplers by using Configuration Elements. They're required to add to Samplers' requests.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Create a Test Plan in JMeter.

Follow the instructions, and you can create a test plan in JMeter.

  1. Open your apache JMeter application. You will see the interface in the image below.
jmeter interface image

The above image has a test plan without any test plan element or attributes like thread group added to it.

2. Now, let's add a test element or attribute to our test plan, which will help us to test our application.

Right-click on the test plan folder and hover over add element to include the test elements in the test plan.

open model

 

3. To remove or delete an element from the test plan, right-click on the element and click on the remove element.

remove

 

4. You can also load an element from the other file with the help of the “merge” element in JMeter. Select your test plan element right, click and then click on merge to load the element into the current test plan.

merge

 

5. The controls found in JMeter's right side frame can be used to configure any element in the test plan. You can configure the behavior of that specific test element using these controls. The Thread Group, for instance, can be set up for various users, ramp-up times, etc.
 

6. Before running your test plan, you need to save it. You can save your test plan by clicking on the save element from the file attribute present in the menu.
 

7. You can start or run your test plan by right-clicking on the test plan and clicking on the start element, clicking on the Green play button on the menu bar, or entering control + r to start the test plan.

start

8. In the end, you should know how to stop your test plan. There are two ways to terminate a test plan in JMeter.

      a. Use control + “ . “ to stop the thread immediately.

      b. You can also use control + “, “ to shut down the threads. 

 

Must Read Apache Server

Frequently Asked Questions

JMeter is based on which programming language?

JMeter is purely based on Java programming language.

What is the functionality of JMeter?

With the help of JMeter, we can achieve load and performance testing of our application.

Can we do functional or regression testing in JMeter?

We can also achieve functional or regression testing according to our needs.

Can we create a test plan without any thread group?

No, we need to include at least one thread group to create a test plan.

Can we set a time interval between thread requests?

Yes, with the help of the timer element in the JMeter test plan, we can achieve time intervals.

Conclusion

In this blog, we discussed the test plan in JMeter. We have also discussed the elements we can use in the JMeter test plan. In the end, we learned how to create a test plan in JMeter.

To learn more about JMeter, check out the following articles.

To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Coding Ninjas Studio. Also, you can enroll in our courses and check out the mock test and problems available to you. Please check out our interview experiences and interview bundle for placement preparations.

Happy Coding!

Previous article
JMeter vs Ready API
Next article
What are JMeter Test Plan Elements?
Live masterclass