Testing / Cucumber Interview Questions
How does Cucumber-JVM handle parallel test execution with the JUnit 5 Platform Suite?
The JUnit 5 Platform Suite engine, the current recommended way to run Cucumber-JVM, integrates with JUnit Platform's own parallel execution support, letting scenarios run concurrently rather than strictly one after another.
# junit-platform.properties cucumber.execution.parallel.enabled=true cucumber.execution.parallel.config.strategy=fixed cucumber.execution.parallel.config.fixed.parallelism=4
With parallel execution enabled, each pickle (compiled scenario) can run on a separate thread, which is where Dependency Injection's per-scenario instantiation actually becomes essential for correctness, not just organization: if step definition instances or their injected shared state were accidentally reused across concurrent scenarios, parallel runs would produce inconsistent, hard-to-reproduce failures from one scenario's state leaking into another's.
Because of this, code that deliberately bypasses per-scenario isolation, static/shared mutable fields, singletons holding scenario-specific state, is the most common source of flaky failures that only appear once parallel execution is turned on, even when the exact same suite passes reliably in sequential mode.
More Related questions...