Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Concepts and Setup

Test Plan Elements, Scope and Execution Order in JMeter

Learn the JMeter element types (samplers, controllers, config, timers, processors, assertions, listeners), how scoping works and the fixed order in which elements run.

A JMeter plan looks like a simple list, but its behaviour comes from two rules that beginners often miss: scope (which elements affect which samplers) and execution order (what runs before and after each request). Misunderstanding them causes the classic puzzles: a timer that delays everything, an assertion that fails the wrong request, a header that is not sent. This lesson gives you the model.

Honesty note. JMeter cannot run here. The rules below follow the official component reference. The runnable block is a stand-in that applies the scoping and ordering rules to a small plan model so you can predict behaviour.

The element families

Family Examples Job
Test Plan Test Plan Root; holds user-defined variables and global settings
Threads Thread Group, setUp, tearDown, Ultimate Thread Group (plugin) Define virtual users
Samplers HTTP Request, JDBC Request, FTP Request, TCP Sampler, JSR223 Sampler Send requests and create samples
Logic controllers Loop, If, While, Transaction, Random, Interleave Decide which samplers run and how often
Config elements HTTP Request Defaults, Header Manager, Cookie Manager, CSV Data Set Config Provide settings and data
Pre-processors User Parameters, JSR223 PreProcessor Prepare a sampler just before it runs
Timers Constant Timer, Uniform Random Timer Pause before each sampler
Post-processors Regular Expression Extractor, JSON Extractor Pull values from a response
Assertions Response Assertion, JSON Assertion, Duration Assertion Mark a sample as failed or passed
Listeners View Results Tree, Summary Report Show or save results

Only samplers talk to the server. Everything else supports, controls or inspects them.

Rule 1: scoping

Non-sampler elements apply to samplers according to where they sit in the tree:

  • An element placed under a sampler applies to that sampler only.
  • An element placed under a controller or Thread Group applies to all samplers at or below that level.
  • An element placed directly under the Test Plan applies to every sampler in the plan (listeners placed here record all samples).
flowchart TD
  TP["Test Plan"] --> H["Header Manager (applies to ALL samplers)"]
  TP --> TG["Thread Group"]
  TG --> T["Constant Timer 500 ms (applies to both samplers)"]
  TG --> S1["Sampler A"]
  TG --> S2["Sampler B"]
  S2 --> AS["Assertion (only Sampler B)"]

Scope follows the parent: the assertion guards Sampler B only, the timer delays both.

Practical consequence: if you put a Constant Timer under the Thread Group, it adds delay before every sampler, not just one. To delay one request only, attach the timer to that sampler (as a child) or wrap the request in a controller.

A particular trap: a Response Assertion placed at Thread Group level checks all samplers below, so a login page and a search page must both satisfy the same pattern. Put assertions under the specific sampler unless a check really is global.

Rule 2: execution order

Within a scope, JMeter does not run elements in the order they appear in the tree. For each sampler it applies this fixed order:

  1. Configuration elements (applied first, so defaults and data are ready)
  2. Pre-processors
  3. Timers (the pause happens here, before the sampler)
  4. Sampler (the request is sent)
  5. Post-processors (only if the sampler produced a result)
  6. Assertions
  7. Listeners

Memorize it as: Config, Pre, Timer, Sampler, Post, Assert, Listen. (Timers run before the sampler, even if you put them below it.)

Samplers and logic controllers, on the other hand, do run in tree order, top to bottom. Within the same type, the nearest-to-the-sampler element wins, with one exception: config elements further down the tree override ones further up (a Header Manager on a sampler overrides one on the Thread Group for conflicting header names, and both are merged otherwise).

Because post-processors run before assertions, an extractor can fetch a value and an assertion can then check it, as in: JSON Extractor saves ${orderId}, then an assertion verifies the response contains it.

Special thread groups

Besides normal Thread Groups, two special ones order the whole run:

  • setUp Thread Group runs before all others: log in once, create test data.
  • tearDown Thread Group runs after all others: clean up data.

Normal Thread Groups run in parallel by default unless you tick Run Thread Groups consecutively on the Test Plan.

Test Fragments and reuse

A Test Fragment is a container that does not run on its own. A Module Controller or Include Controller can call it, so the same "login steps" are written once and reused from many places. This keeps big plans maintainable.

Stand-in: predict what applies and in what order

This stand-in implements the scoping rule (elements apply to all samplers below their parent) and prints the effective order for each sampler.

JS Stand-in: compute scope and execution order

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice that sampler A has no assertion and no extractor, but it does get the Header Manager, the timer and the listener from the levels above it, while B also gets its own extractor and assertion.

A debugging checklist

When something "does not apply":

  1. Is the element a child of (or above) the sampler in the tree?
  2. Is it disabled (greyed)?
  3. Does the sampler produce a result? (Post-processors skip samplers that returned nothing.)
  4. Is a closer element overriding a more distant one?
  5. Use a View Results Tree under the sampler to see the actual request headers and body that were sent.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. An assertion is a child of a Thread Group. Which samplers does it check?

    Elements apply to all samplers in the scope of their parent, so a Thread Group level assertion checks every sampler below it.
  2. 2. Which is the correct execution order around one sampler?

    JMeter applies configuration, pre-processors and timers before the sampler, then post-processors, assertions and listeners.
  3. 3. What does a setUp Thread Group do?

    setUp runs first; tearDown runs last.
  4. 4. Only one element type actually sends requests to the server. Which one?

    Samplers send requests and generate samples; all other elements support or inspect them.

Summary

  • Samplers send requests; controllers, config elements, timers, processors, assertions and listeners support them.
  • Scope: an element applies to the samplers at or below its parent.
  • Order per sampler: Config, Pre-processors, Timers, Sampler, Post-processors, Assertions, Listeners.
  • setUp and tearDown thread groups bracket the main run; test fragments allow reuse.
  • Check position, disabled state and a Results Tree when behaviour surprises you.

Next: Thread Groups and the Load Model