In this section, you will learn how to add a tearDown Thread Group to configure the post-test actions (such as committing a transaction, disconnecting from the database, destroying the session etc.).
The tearDown Thread Group is used to perform post-test actions. These actions should be configured within the tearDown Thread Group and not within the regular Thread Group that you will use for running your load test.
In this guide, you will run the following post-test actions via tearDown Thread Group:
-
Commit the transaction
-
Destroy the user session
Normally the tearDown Thread Group runs only once.
To add a tearDown Thread Group to the test plan, right click on the test plan that you added just now, and then select Add > Threads (Users) > tearDown Thread Group.
Make sure this tearDown Thread Group is listed after Thread Group, so it starts when Thread Group has finished.
You can use the default settings for the tearDown Thread Group. Normally the tearDown Thread Group runs only once.
Now you can move (by drag & drop) the following HTTP requests from Thread Group to the setUp Thread Group.
To correlate the transaction ID, you can first add a Regular Expression Extractor to save the transaction ID into a local variable; and then add a BeanShell PostProcessor to set the local variable as a global property, so that it can be shared in all thread groups.
To add a Regular Expression Extractor, right click on the CommitAndCreateTransaction request and then select Add > Post Processors > Regular Expression Extractor.
Specify the Regular Expression Extractor like this:
-
Name of created variable: "transaction" or any other name you prefer
-
Regular Expression: 9,0,null,"(.+?)",0,0,null],"content
-
Template: $1$
-
Match No.: 1
The transaction ID will be saved to the
"transaction
" variable.
To add a BeanShell PostProcessor, right click on the CommitAndCreateTransaction request and then select Add > Post Processors > BeanShell PostProcessor.
Input the following script:
${__setProperty(transaction,${transaction},)}
The "transaction
" variable can be accessed as
a JMeter global property.
Find the transaction ID in all thread groups, and then
replace the static value of transaction ID with the global
property ${__property(transaction,,)}
. See Correlating the
transaction ID for more instructions.