In this chapter of Thread Group in JMeter Test Plan, we will be covering the following topics:
- What is Thread Group
- How to Create a Thread Group
- Component of Thread Group
To understand the JMeter Test Plan, please visit the previous tutorial (Building Test Plan in JMeter)of this series.
What is Thread Group in JMeter?
A Thread Group is a set of threads executing the same scenario. Set the number of iterations in the configuration. Thread behaviour is defined according to ramp up and destroyed once the number of iterations per thread has elapsed. This is how a Thread Group Element looks:
Thread Group elements are the initial steps of JMeter Test Plan. A number of threads(users) can be defined in a Thread Group. Each thread simulates a real user requesting to the server under a test.
If you set the number of threads as 20; JMeter will create and simulate 20 virtual users during the load test. A diagram here can help us understand it better
How to Create a Thread Group Element in JMeter Test Plan?
In the previous chapter we learnt that how to create a test plan. Thread Group is a element of test plan. To create a Thread Group it is required to have the Test Plan created.
- Start JMeter
- Select Test Plan on the tree
- Add Thread Group
Open the thread group panel by Right Click on Test Plan and then going to Add >> Threads >> Thread Group. As shown in the image below:
Components of Thread Group
The Thread Group Panel holds the following components −
1) Action to be taken after a Sampler Error
If JMeter catch any sampler error during test execution, you can tell it how to react in that scenario from the following available options.
- Continue, to ignore error and move to the next element in the tree
- Start Next Thread Loop to stop current Thread and Start Next
- Stop Thread, to stop the current Thread execution.
- Stop Test, to stop entire test execution.
- Stop Test Now, the entire test will be stopped abruptly.
Default is Continue.
2) Thread Properties
- Number of Threads (users): Simulates the number of users or connections to your server application.
- Ramp-Up Period (in seconds): Tells JMeter how long to take ramp-up to the full number of threads chosen. For Example: If you set “Number of Threads” to “20”, and “Ramp-Up Period to “40” seconds, then JMeter will wait till 40 seconds to make all threads up and running. That means each thread will start 2 seconds late after the previous thread was started.
- Formula: Ramp-Up Period / Number of Threads i.e. 40 / 20 = 2 (seconds)
- Loop Count: the number of times the test to be executed. If you need to run the test forever, then select the “Forever” check box.
- Scheduler: To schedule test execution. Scheduler Configuration bottom panel will get enabled when you select this checkbox. The schedule feature is also very helpful in soak/endurance testing.
3) Scheduler Configuration
You can configure test start time, end time, duration and start up delay of your load test plan using Scheduler Configuration section. To enable this area of configuration, Scheduler check box must be selected from the above Section of Thread Properties.
Thread Group configuration panel is as follows:
- Start Time: This plans the test to start at scheduled time. Pre Condition is that the JMeter should be running on given date and time in “Start Time” field.
- End Time: This command JMeter to end the test at the mentioned time. End time override and stop execution in between. Means End Time is maximum allowed time to finish execution of the test plan. JMeter ends the execution immediately as soon as End Time is occur.
- Duration (seconds): This tell the JMeter to execute the test for the specific duration of time. If the duration is set to 60 secs, JMeter will keep the execution on for 60 secs and ends it once the time is elapsed. It also ignores or override the End Time and All threads has completed its test or not.
- Startup delay (seconds): This tells JMeter to wait for specified time before starting the test. If the StartUp time is set to 10 secs, JMeter will not start loading the Users till the time 10 secs are over.