Scenario Outline iteration and @Before/@After hook lifecycle
0 reputation · 14 Jul 2021, 02:29 UTC
Scenario Outline Execution Behavior
Cucumber-JVM utilizes Scenario Outlines to execute a single scenario multiple times based on the rows provided in an Examples table. Each row is treated as an independent scenario for the purpose of reporting and execution.
Hook Lifecycle Constraints
When integrating Cucumber with external test runners like JUnit or TestNG, the lifecycle of @Before and @After hooks must align with each iteration of the Examples table to ensure test isolation. However, the precise interaction between these hooks and the iteration cycle can vary depending on the runner configuration.
What is the guaranteed execution order of hooks when a Scenario Outline is processed across multiple rows? Does the framework ensure a clean state by triggering the full hook lifecycle for every individual row in the Examples table regardless of the runner used?