jMeter - Test Plan Elements

A JMeter Test Plan comprises of test elements discussed below. A Test Plan comprises of at least one Thread Group. Within each Thread Group, we may place a combination of one or more of other elements − Sampler, Logic Controller, Configuration Element, Listener, and Timer. Each Sampler can be preceded by one or more Pre-processor element, followed by Post-processor element, and/or Assertion element. Let us see each of these elements in detail −

Thread Group

Thread Group elements are the beginning points of your test plan. As the name suggests, the thread group elements control the number of threads JMeter will use during the test. We can also control the following via the Thread Group −
  1. Setting the number of threads
  2. Setting the ramp-up time
  3. Setting the number of test iterations
The Thread Group Control Panel looks like this −
Thread Group
The Thread Group Panel holds the following components −
  • Action to be taken after a Sampler error − In case any error occurs during test execution, you may let the test either −
    • Continue to the next element in the test
    • Stop Thread to stop the current Thread.
    • Stop Test completely, in case you want to inspect the error before it continues running.
  • Number of Threads − Simulates the number of users or connections to your server application.
  • Ramp-Up Period Defines how long it will take JMeter to get all threads running.
  • Loop Count − Defines the number of times to execute the test.
  • Scheduler checkbox − Once selected, the Scheduler Configuration section appears at the bottom of the control panel.
  • Scheduler Configuration − You can configure the start and end time of running the test.

Controllers

JMeter has two types of Controllers − Samplers and Logic Controllers.

Samplers

Samplers allow JMeter to send specific types of requests to a server. They simulate a user request for a page from the target server. For example, you can add a HTTP Request sampler if you need to perform a POST, GET, or DELETE on a HTTP service.
Some useful samplers are −

  1. HTTP Request
  2. FTP Request
  3. JDBC Request
  4. Java Request
  5. SOAP/XML Request
  6. RPC Requests
The following screenshot shows an HTTP Request Sampler Control Panel −
Sampler Control Panel

Logic Controllers

Logic Controllers let you control the order of processing of Samplers in a Thread. Logic controllers can change the order of a request coming from any of their child elements. Some examples are − ForEach Controller, While Controller, Loop Controller, IF Controller, Run Time Controller, Interleave Controller, Throughput Controller, and Run Once Controller.
The following screenshot shows a Loop Controller Control Panel −
Logic Controller Panel
The following list consists of all the Logic Controllers JMeter provides −
  1. Simple Controller
  2. Loop Controller
  3. Once Only Controller
  4. Interleave Controller
  5. Random Controller
  6. Random Order Controller
  7. Throughput Controller
  8. Runtime Controller
  9. If Controller
  10. While Controller
  11. Switch Controller
  12. ForEach Controller
  13. Module Controller
  14. Include Controller
  15. Transaction Controller
  16. Recording Controller

Test Fragments

A Test Fragment is a special type of element placed at the same level as the Thread Group element. It is distinguished from a Thread Group in that it is not executed unless it is referenced by either a Module Controller or an Include_Controller. This element is purely for code re-use within Test Plans.

Listeners

Listeners let you view the results of Samplers in the form of tables, graphs, trees, or simple text in some log files. They provide visual access to the data gathered by JMeter about the test cases as a Sampler component of JMeter is executed.
Listeners can be added anywhere in the test, including directly under the test plan. They will collect data only from elements at or below their level. The following list consists of all the Listeners JMeter provides −

  1. Sample Result Save Configuration
  2. Graph Full Results
  3. Graph Results
  4. Spline Visualizer
  5. Assertion Results
  6. View Results Tree
  7. Aggregate Report
  8. View Results in Table
  9. Simple Data Writer
  10. Monitor Results
  11. Distribution Graph (alpha)
  12. Aggregate Graph
  13. Mailer Visualizer
  14. BeanShell Listener
  15. Summary Report

Timers

By default, a JMeter thread sends requests without pausing between each sampler. This may not be what you want. You can add a timer element which allows you to define a period to wait between each request.
The following list shows all the timers that JMeter provides −

  1. Constant Timer
  2. Gaussian Random Timer
  3. Uniform Random Timer
  4. Constant Throughput Timer
  5. Synchronizing Timer
  6. JSR223 Time
  7. BeanShell Time
  8. BSF Time
  9. Poisson Random Time
The following screenshot shows a Constant Timer Control Panel −
Constant Timer Panel

Assertions

Assertions allow you to include some validation test on the response of your request made using a Sampler. Using assertions you can prove that your application is returning the correct data. JMeter highlights when an assertion fails.
The following list consists of all the assertions JMeter provides −

  1. Beanshell Assertion
  2. BSF Assertion
  3. Compare Assertion
  4. JSR223 Assertion
  5. Response Assertion
  6. Duration Assertion
  7. Size Assertion
  8. XML Assertion
  9. BeanShell Assertion
  10. MD5Hex Assertion
  11. HTML Assertion
  12. XPath Assertion
  13. XML Schema Assertion
The following screenshot shows a Response Assertion Control Panel −
Response Assertion Panel

Configuration Elements

Configuration Elements allow you to create defaults and variables to be used by Samplers. They are used to add or modify requests made by Samplers.
They are executed at the start of the scope of which they are part, before any Samplers that are located in the same scope. Therefore, a Configuration Element is accessed only from inside the branch where it is placed.
The following list consists of all the Configuration Elements that JMeter provides −
  1. Counter
  2. CSV Data Set Config
  3. FTP Request Defaults
  4. HTTP Authorization Manager
  5. HTTP Cache Manager
  6. HTTP Cookie Manager
  7. HTTP Proxy Server
  8. HTTP Request Defaults
  9. HTTP Header Manager
  10. Java Request Defaults
  11. Keystore Configuration
  12. JDBC Connection Configuration
  13. Login Config Element
  14. LDAP Request Defaults
  15. LDAP Extended Request Defaults
  16. TCP Sampler Config
  17. User Defined Variables
  18. Simple Config Element
  19. Random Variable

Pre-processor Elements

A pre-processor element is something that runs just before a sampler executes. They are often used to modify the settings of a Sample Request just before it runs, or to update variables that are not extracted from response text.
The following list consists of all the pre-processor elements that JMeter provides −
  1. HTML Link Parser
  2. HTTP URL Re-writing Modifier
  3. HTTP User Parameter Modifier
  4. User Parameters
  5. JDBC PreProcessor
  6. JSR223 PreProcessor
  7. RegEx User Parameters
  8. BeanShell PreProcessor
  9. BSF PreProcessor

Post-processor Elements

A post-processor executes after a sampler finishes its execution. This element is most often used to process the response data, for example, to retrieve a particular value for later use.
The following list consists of all the Post-Processor Elements JMeter provides −

  1. Regular Expression Extractor
  2. XPath Extractor
  3. Result Status Action Handler
  4. JSR223 PostProcessor
  5. JDBC PostProcessor
  6. BSF PostProcessor
  7. CSS/JQuery Extractor
  8. BeanShell PostProcessor
  9. Debug PostProcessor

Execution Order of Test Elements

Following is the execution order of the test plan elements −

  1. Configuration elements
  2. Pre-Processors
  3. Timers
  4. Sampler
  5. Post-Processors (unless SampleResult is null)
  6. Assertions (unless SampleResult is null)
  7. Listeners (unless SampleResult is null)