JMeter – setUp Thread Group

setUp Thread Group is a special type of JMeter Thread Group that can be utilized to perform Pre-Test actions. The behaviour of the setUp Thread Group is as same as the normal Thread Group element. The only difference is that the setUp Thread Group executes before the test proceeds to execute the normal Thread Group.

Similarly, tearDown Thread Group helps to perform Post-Test activities.

What is the use of ‘setUp Thread Group’?

setUp Thread Group is very much helpful to perform pre-test activities like:

  • To create new users by doing the sign-up activity
  • It is used to get a large dataset from a database into a JMeter variable that can be used during the test
  • To get and log the version number from the system under test version number.
  • To run a javascript to set JMeter properties based on more simple input parameters/properties. Let’s say you want to configure the selection of the target host to a simple true/false value, but in your test, you need to expand it to different strings, and you do not want to have logic spread out all over your test plan.5. To apply some pre-test condition based on that Thread Group (Test Case) will be selected.

How to add ‘setUp Thread Group’ in the script?

You can follow below steps:

  1. Select ‘Test Plan’ node
  2. Right-click on the ‘Test Plan’ node
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘Thread (Users)’
  5. Click ‘setUp Thread Group’
setUp Thread Group
Figure 01: setUp Thread Group

Input fields of the ‘setUp Thread Group’ element:

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

  1. Name: To provide setUp Thread Group name. It could be a Test Case/Test Scenario name
  2. Comments: To write the comment related to setUp 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, stop the current thread only with the error.
    4. Stop Test: When an error occurs, 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, 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 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. 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 the scheduling a test in JMeter, refer to the article How to schedule JMeter test?
  9. 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.
  10. Startup delay (seconds): If you provide value for ‘Startup delay’ then JMeter adds the specified delay to start the test after pressing ‘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 word, the test starts at a time (=current system time + startup delay)

Possible Parent Element:

  1. Test Plan

Possible Child Element(s):

  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:

2 thoughts on “JMeter – setUp Thread Group”

  1. I had a question. How to execute a script for 1200user hit the application with 25transactions per sec with in 1.5hrs.how to set the thread group for this script.

    Reply

Leave a Comment