JMeter – Thread Group

A Thread Group defines a pool of users that execute a particular test case as per your SLA. You can consider Thread Group as a Virtual User Group that performs a set of steps which you have recorded. The Thread Group element helps to define a performance test scenario in JMeter. In Thread Group GUI, you can control the number of simulated users (threads), the ramp-up time (how long it takes to start all the threads), the loop count (or iteration count, and optionally, a start and stop time for the test.

How to add ‘Thread Group’ element in JMeter script?

You can follow the below steps:

  1. Select ‘Test Plan‘ node and right-click on it.
  2. Hover the mouse on ‘Add’
  3. Hover the mouse on ‘Thread (Users)’
  4. Click ‘Thread Group’
JMeter - Thread Group Element
Figure 01: Thread Group Element

Input fields of the ‘Thread Group’ element:

The ‘Thread Group’ element has the following input fields:

  1. Name: To provide Thread Group name. It could be a Test Case/Test Scenario name
  2. Comments: To write a comment related to Thread Group
  3. Action to be taken after a Sampler error: Actions taken in case of sampler error occurs, either because the sample itself failed or an assertion failed etc. The possible choices are:
    1. Continue: When an error occurs then ignore the error and continue with the test.
    2. Start Next Thread Loop: When an error occurs then ignore the error, start next loop and continue with the test
    3. Stop Thread: When an error occurs then stop the current thread only which has the error.
    4. Stop Test: When an error occurs then stop the entire test when the current sampler of other threads completed the execution.
    5. Stop Test Now: When an error occurs in any thread then the entire test will stop abruptly. Any current sampler execution may interrupt.
  4. Number of Threads (Users): Number of users to simulate during the performance test.
  5. Ramp-up Period (seconds): How long JMeter should take to get all the threads started? If there are 10 threads and a ramp-up time of 100 seconds then each thread will be initiated at the interval of 10 seconds and at 100th second all the threads get started.
    Note: This is not the time between two threads to start-up.
  6. Loop CountNumber of times to iterate the test case. Alternatively, you can checkmark ‘Infinite’ to stop the test when the specified duration is over or stop the test manually.
  7. Same user on each iteration: On selecting the checkbox ‘Same user on each iteration’, when JMeter gets the cookie in the first response then it saves the cookie and uses in the following requests; provided that you have added HTTP Cookie Manager.
  8. Delay Thread creation until neededIf checked the box then threads are created only when the appropriate proportion of the ramp-up time has elapsed. This is most appropriate for tests with a ramp-up time that is significantly longer than the time to execute a single thread. If not checked, all threads are created when the test starts.
  9. Specify Thread lifetime: Checkmark the box if you want to run the test for a particular duration or schedule a test. To get more information on scheduling a test in JMeter, refer to the article How to schedule JMeter test?
  10. Duration (seconds): This denotes the total duration of the test. Once you select the ‘Infinite’ option for ‘Loop Count’ then you need to provide the duration of the test to control the test execution.
  11. Startup delay (seconds): If you provide value for ‘Startup delay’ then JMeter adds the specified delay to start the test after pressing the ‘Run’ button. In Non-GUI mode, after hitting the test execution command, JMeter does not fire any request until the specified delay period is over. In simple words, the test starts at a time (=current system time + startup delay)

Possible Parent element(s) of Thread Group:

  1. Test Plan

Possible Child Element(s) of Thread Group:

  1. Sampler
  2. Config Element
  3. Logic Controller
  4. PreProcessor
  5. PostProcessor
  6. Assertion
  7. Timer
  8. Listener
  9. Test Fragment

Element(s) can not be added as a child element:

  1. Non-Test Element
  2. Test Plan
  3. Another Thread Group

You may be interested:

Leave a Comment