What is purpose to use setup threadgroup and teardown threagroup in Jmeter? Please explain same with example

What is purpose to use setup threadgroup and teardown threagroup in Jmeter? Please explain same with example.

I know why we use thread groups and also aware of fact that setup is for pre activities like creating user and monitoring purpose but not sure with an incident where can i use it. same with tear down.

Upvotes: 1

Views: 5827

Answers (3)

user2549417
user2549417

Reputation: 21

correct me as i'm probably wrong, but a setUp thread cannot be used to store variables for use on the test threads (that i can see). any variables that i use in the setUp are never available. however, i found that if i use a beanshell and convert the variable in the setUp thread to a property like this ${__setProperty(userToken, ${userToken})};

then on each test thread i either use the property directly like:

${__property(userToken)}

or at the top of my thread i convert the property back into a variable like: vars.put("userToken","${__property(userToken)}")

however, this seems a bit long winded and it would be great if there was a way to set up variables in the setUP to be used on every thread.

Upvotes: 2

Narayan
Narayan

Reputation: 1

A special type of ThreadGroup that can be utilized to perform Pre-Test/ Post-Test Actions.The behavior of these threads is exactly like a normal Thread Group element. The difference is that these type of threads execute before/after the test has finished executing its regular Thread Groups.enter image description here

Upvotes: 0

Cyberwiz
Cyberwiz

Reputation: 11426

It sounds like you have pretty much figured it out already, but let me give you a few examples of when I've used it.

setup:

  • Get a large data set from a database into a jmeter variable for use during the test.
  • Get and log the version number from the system under test:s version number.
  • Run a javascript to set jmeter properties based on more simple input parameters/properties. Lets say you want to configure the selection of target host a simple true/false value, but in your test you need to expand it to different strings, and you dont want to have logic spread out all over your test plan.

teardown:

  • Never used it, but I guess it is mainly useful for cleaning up your system (e.g. deleting users that were created during the test)

Upvotes: 2

Related Questions