Expand description
Worker-process metadata exposed to user-defined dependency factories.
The test runner spawns one worker subprocess per test thread when output
capturing is on (see [crate::sync]/[crate::tokio]). Each spawned
worker is assigned a zero-based worker index by the parent. PerWorker
dependency constructors can read that index via worker_index to seed
per-worker state (for example, a unique-id counter that must not collide
with other workers).
When the test harness runs without spawning workers (the parent process
itself runs every test, e.g. under --nocapture, when no Shared deps
force serial execution, or when nothing requires capture in the first
place), worker_index returns 0.
Functionsยง
- worker_
index - Returns the zero-based worker index assigned to this OS process.