Testing / Apache JMeter Interview questions
Explain the execution flow of a JMeter test plan with nested thread groups and controllers?
Execution starts at the Test Plan level, where JMeter initializes any Test Plan-scoped Config Elements and User Defined Variables before any Thread Group actually begins running, making that shared configuration available to everything nested beneath it.
Each Thread Group then starts its configured number of threads according to its ramp-up period; within a single thread, JMeter walks through the elements nested inside that Thread Group top-to-bottom, in the order they appear in the tree - samplers execute, controllers evaluate their condition or repeat logic and recurse into their own nested children, and timers pause execution at the point they're encountered.
When a Logic Controller like a Loop Controller or If Controller is reached, JMeter doesn't just skip past it - it evaluates the controller's own logic (repeat count, condition) and then executes everything nested inside that controller according to that logic, potentially multiple times or not at all, before continuing on to whatever comes after the controller at the parent level.
Pre-Processors and Post-Processors attached to a sampler run immediately before and after that specific sampler's execution respectively, and Assertions attached to a sampler evaluate immediately after it completes, all within that same single pass through the tree - there's no separate assertion or post-processing phase that runs afterward across the whole test.
Once a thread finishes its configured loop count (or its While/Loop Controller conditions are satisfied and no further repeats remain), that thread ends; the overall test completes once every thread across every Thread Group has finished, at which point any Test Plan-level teardown (like tearDown Thread Groups, if configured) runs.
flowchart TD
A[Test Plan starts: init Config Elements] --> B[Thread Group: start threads per ramp-up]
B --> C[Thread walks elements top to bottom]
C --> D{Element type?}
D -- Sampler --> E[Pre-Processors run, request sent, Post-Processors run, Assertions evaluate]
D -- Logic Controller --> F[Evaluate condition/repeat, recurse into nested elements]
D -- Timer --> G[Pause execution]
E --> H{More elements in thread?}
F --> H
G --> H
H -- Yes --> C
H -- No --> I[Thread ends / loops per Thread Group config]
More Related questions...
