setUp Thread Group is a special type of JMeter Thread Group that can be utilized to perform Pre-Test actions. The behaviour of setUp Thread Group is as same as the normal Thread Group element. The only difference is that setUp Thread Group executes before the test proceeds to execute 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 tests version number.
How to add ‘setUp Thread Group’ in the script?
You can follow below steps:
- Select ‘Test Plan’ node
- Right-click on the ‘Test Plan’ node
- Hover the mouse on ‘Add’
- Hover the mouse on ‘Thread (Users)’
- Click ‘setUp Thread Group’
Input fields of the ‘setUp Thread Group’ element:
‘setUp Thread Group’ element has following input fields:
- Name: To provide setUp Thread Group name. It could be a Test Case/Test Scenario name
- Comments: To write the comment related to setUp Thread Group
- 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:
- Continue: When an error occurs then ignore the error and continue with the test.
- Start Next Thread Loop: When an error occurs then ignore the error, start next loop and continue with the test
- Stop Thread: When an error occurs then stop the current thread only which has the error.
- Stop Test: When an error occurs then stop the entire test when the current sampler of other threads completed the execution.
- Stop Test Now: When an error occurs in any thread then the entire test will stop abruptly. Any current samplers execution may interrupt.
- Number of Threads (Users): Number of users to simulate during the performance test.
- 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.
- Loop Count: Number 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.
- 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.
- 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?
- 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.
- 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:
- Test Plan
Possible Child Element(s):
- Config Element
- Logic Controller
- Test Fragment
Following Element(s) can not be added as a child element:
- Non-Test Element
- Test Plan
- Another Thread Group