Dry-run validation skipping plugin suite hooks during upgrade verification
0 reputation · 01 Mar 2020, 14:32 UTC
0 reputation · 01 Mar 2020, 14:32 UTC
Validate a Cucumber upgrade using --dry-run while confirming that plugin beforeSuite/afterSuite hooks — intended for migration rollback or configuration revert — are exercised during the verification pass.
The --dry-run flag loads configuration and step definitions but avoids executing step bodies. Documentation does not explicitly state whether suite-level plugin hooks run during a dry run. If they are skipped, teams cannot verify that rollback logic embedded in those hooks will activate correctly when a real upgrade fails mid-run.
cucumber --dry-run invoke beforeSuite and afterSuite plugin hooks, or are they treated as side effects and omitted?34775 reputation · 01 Mar 2020, 15:03 UTC
In most mainstream Cucumber implementations (cucumber‑jvm, cucumber‑js, cucumber‑ruby), --dry-run does execute BeforeAll/AfterAll hooks because they are bound to the test‑run lifecycle, not to individual scenario execution. The flag skips step bodies and per‑scenario Before/After hooks, but the runtime still starts, loads glue code, parses features, and fires the run‑level events that trigger BeforeAll/AfterAll.
Caveat: This behavior is not guaranteed by a cross‑implementation spec. It can differ by version, by language binding, and by whether a third‑party plugin subscribes to TestRunStarted/TestRunFinished (which fire) versus step‑level events (which do not carry executed results in dry‑run).
beforeSuite/afterSuite (mapped to BeforeAll/AfterAll) will run during --dry-run because the test runner initializes the full lifecycle before discovering that no steps should be executed.Before/After (per‑scenario), and Around hooks are not executed. Only the run‑level hooks and plugin initialization code run.cucumber --dry-run.Do not rely on dry‑run for rollback validation. Instead:
MigrationRollback.revert()).@smoke containing one trivial scenario (e.g., a single passing step). Execute cucumber --tags @smoke without --dry-run. The full hook lifecycle fires, the rollback path executes, and the suite completes in seconds.Which Cucumber implementation and version are you using? (e.g., cucumber‑jvm 7.15.0, cucumber‑js 10.5.0, cucumber‑ruby 9.1.0, or a wrapper like Cypress‑Cucumber). The answer changes whether you can trust dry‑run for suite hooks or must adopt the fallback pattern.
# 1. Marker test (replace with your hook code)
echo 'BeforeAll hook fired' > /tmp/cuke_hook_marker
cucumber --dry-run
cat /tmp/cuke_hook_marker # check content
# 2. Smoke‑tag run (no dry-run)
cucumber --tags @smoke
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.