Cucumber.RunCoordinator (Cucumber v1.0.0)
View SourceRun-wide coordination process for cucumber test runs.
Started (or reset) by Cucumber.compile_features!/1 — which runs from
test_helper.exs before any test executes, so startup is race-free. State
is keyed by a run id that changes on every compile_features! call, so
repeated runs in one VM (mix test.watch, test harnesses) never see stale
state.
Current run-scoped concerns:
- BeforeAll once-guard —
before_all_context/1runs the run'sbefore_allhooks exactly once (serialized through the GenServer, so concurrent@asyncscenarios are safe) and caches the merged context (or the first error) for every subsequent scenario. - AfterAll hand-off —
register_after_all/1stores the run'safter_allhooks; theExUnit.after_suite/1callback registered by the compiler claims them exactly once viarun_after_all/1. - Attachments —
record_attachment/2collectsCucumber.Attachmentstructs (seeCucumber.attach/4) in run order;attachments/0returns them. - Cucumber Messages sink — when
config :cucumber, messages: pathis set,Cucumber.Messages.Emitterconfigures the sink with the run's static envelopes and id maps (configure_messages/1); the runner then appends run-time envelopes in order (emit_runtime/1,take_message_ids/1,finish_test_case/3), and theafter_suitecallback flushes the NDJSON file (flush_messages/1), reconciling test cases the runner never finished (e.g. a killed test process). Serializing emission through this process is what keeps the stream ordered under@asyncfeatures. Note thatExUnit.after_suite/1callbacks fire on everyExUnit.run/1— the sink flushes (and disables itself) when the first run in the VM completes, so a project that invokes a nestedExUnit.run/1mid-suite with the sink enabled gets the stream truncated at that point (Cucumber.BehaviorCaserelies on exactly this per-run firing to capture streams in tests).
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the coordinator for a new run, or resets it if already running.
Returns the current run id.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec ensure_started() :: integer()
Starts the coordinator for a new run, or resets it if already running.
Returns the new run id.
@spec run_id() :: integer()
Returns the current run id.