7. Test plans and components

Basically, using JMeter consists of the creation, configuration and execution of test plans and the analysis of their results. Test plans are sets of requests against local or remote servers (or clients) configured to run by following specific instructions.

In the configuration of a test plan you can specify several input and output parameters and you can configure the basic conditions that should be met so the test plan is successful or not.
JMeter test plans are composed of different components. Here is a list of the most important ones with instructions about how you can add them using the JMeter UI and what their purpose is:

7.1 ThreadGroup

A thread group is basically a combination of different test plan elements. It is the root of a test plan and it controls the basic central parameters.
In order to create a test plan you may have to create at first a thread group and configure its number of threads, the ramp-up period, the loop counts and the behavior in case or error:
  • Number of threads: The number of threads that are going to be used to execute the test plan, very important to configure load and stress tests.
  • Ramp-up period: Time that JMeter will need to start all threads.
  • Loop count: Number of iterations, that is the amount of times that the test is going to be executed.
  • Error behavior: What to do in case of error: Stop current thread, stop the whole test, continue…
A Thread Group has also the start and end time configuration options. By clicking the checkbox “Scheduler” a new section with the schedule parameters will appear and you can configure the start and end time of your test.
Once this is configured you can start adding other test plan elements to your Thread group like samplers, listener and timers. We are going to explain all these in the next chapters.

7.2 Samplers

Samplers are used for sending requests to different kind of servers. They are the basic element of every test plan and everything works around them: they execute requests (based on the configuration provided) and these requests produce one or more responses that are analyzed afterwards.
Here is a list of the Samplers available in JMeter (we are going to see some of them in this tutorial):
  • Access log sampler
  • AJP sampler
  • Bean shell sampler
  • BSF sampler
  • Debug sampler
  • FTP sampler
  • HTTP sampler
  • Java sampler
  • JDBC sampler
  • JMS (several) samplers
  • JSR223 sampler
  • JUnit sampler
  • LDAP (several) samplers
  • Mail Reader
  • MongoDB sampler
  • OS process sampler
  • SMTP sampler
  • SOAP
  • TCP samplers
  • Test action
As we can see in the list above, there are a lot of different types of samplers; this list is not complete since there are several samplers implemented in different JMeter plugins. The configuration of each sampler depends on the request that it executes, that means that some samplers have things in common but others are completely different because of the nature of their requests.

7.3 Logic controllers

Logic controllers are elements that allow you to configure the order of execution of different samplers inside a Thread group. This list contains all available logic controllers in JMeter:
  • Simple Controller
  • Loop Controller
  • Once Only Controller
  • Interleave Controller
  • Random Controller
  • Random Order Controller
  • Throughput Controller
  • Runtime Controller
  • If Controller
  • While Controller
  • Switch Controller
  • ForEach Controller
  • Module Controller
  • Include Controller
  • Transaction Controller
  • Recording Controller

7.4 Listeners

Listeners provide different ways to view the results produced by a Sampler requests. Listeners parse results in form of tables, trees or plain log files.
They can be added anywhere in a test plan, but they will only parse and collect result data from the samplers at their level or in the levels bellow.
These are the available listeners in JMeter:
  • Sample Result Save Configuration
  • Graph Full Results
  • Graph Results
  • Spline Visualizer
  • Assertion Results
  • View Results Tree
  • Aggregate Report
  • View Results in Table
  • Simple Data Writer
  • Monitor Results
  • Distribution Graph (alpha)
  • Aggregate Graph
  • Mailer Visualizer
  • BeanShell Listener
  • Summary Report

7.5 Timers

You can define the time period that you want to wait between requests using timers. If you do not specify any, JMeter will execute the next request immediately after the current one is finished, without any waiting time.
Following timers are available in JMeter:
  • Constant Timer
  • Gaussian Random Timer
  • Uniform Random Timer
  • Constant Throughput Timer
  • Synchronizing Timer
  • JSR223 Time
  • BeanShell Time
  • BSF Time
  • Poisson Random Time

7.6 Assertions

Assertions confirm the validity of the test plan by validating the response produced by a Sampler request. Basically assertions are similar to unit test assertions and check the quality of the tested application response. You can configure what kind of assertions is active for every test plan.
Here is a list of available assertions in JMeter:
  • Bean shell Assertion
  • BSF Assertion
  • Compare Assertion
  • JSR223 Assertion
  • Response Assertion
  • Duration Assertion
  • Size Assertion
  • XML Assertion
  • BeanShell Assertion
  • MD5Hex Assertion
  • HTML Assertion
  • XPath Assertion
  • XML Schema Assertion

7.7 Configuration nodes

You can pass different parameters to the sampler requests by using configuration elements. They provide a way to create variables (different and dynamically) that can be used by the samplers afterwards. They are executed at the beginning of the node they belong to, before the samplers are executed, that is why the samplers can rely on these variables.
Here is a list of all the configuration nodes that can be used in JMeter:
  • Counter
  • CSV Data Set Config
  • FTP Request Defaults
  • HTTP Authorization Manager
  • HTTP Cache Manager
  • HTTP Cookie Manager
  • HTTP Proxy Server
  • HTTP Request Defaults
  • HTTP Header Manager
  • Java Request Defaults
  • Keystore Configuration
  • JDBC Connection Configuration
  • Login Config Element
  • LDAP Request Defaults
  • LDAP Extended Request Defaults
  • TCP Sampler Config
  • User Defined Variables
  • Simple Config Element
  • Random Variable

7.8 Pre processors

Pre processors are elements (actions, assertions or basically whatever) that is going to happen before a sampler is executed. They can be used to extract variables from a response that can be used in the sampler afterwards via configuration elements.
These are the elements that can be used as pre processors:
  • HTML Link Parser
  • HTTP URL Re-writing Modifier
  • HTTP User Parameter Modifier
  • User Parameters
  • JDBC PreProcessor
  • JSR223 PreProcessor
  • RegEx User Parameters
  • BeanShell PreProcessor
  • BSF PreProcessor

7.9 Post processors

Is basically an element that is executed after a sampler execution finishes. It can be used to parse the response data and extract values that can be used afterwards.
These elements can be used as post processors:
  • Regular Expression Extractor
  • XPath Extractor
  • Result Status Action Handler
  • JSR223 PostProcessor
  • JDBC PostProcessor
  • BSF PostProcessor
  • CSS/JQuery Extractor
  • BeanShell PostProcessor
  • Debug PostProcessor