Skip to content

Deterministic scheduling for tests

Category: Testing and tools · Status: stub · Lessons: chapter 09, Testing and tools (planned)

One line: Running concurrent code under a controlled scheduler or a fake clock, so that an interleaving or a timeout can be reproduced on demand — Rust's loom, Go's testing/synctest.

Also called: loom, synctest, deterministic simulation, virtual time.

How it connects

flowchart LR
  n_deterministic_testing["Deterministic scheduling for tests"]
  n_heisenbug["Heisenbug"]
  n_deterministic_testing -->|prevents| n_heisenbug
  classDef center stroke-width:3px
  class n_deterministic_testing center
  classDef outside stroke-dasharray: 4 3
  class n_heisenbug outside

In each language

Rust loom ↗ runs a test many times, permuting the possible concurrent executions of it
Go testing/synctest, new in Go 1.25 ↗: a bubble with a fake clock, and Wait until every other goroutine in it is durably blocked
C# Microsoft's Coyote ↗ writes concurrency unit tests that control a .NET program's non-determinism
Kotlin runTest in kotlinx-coroutines-test skips delays using the virtual time of a TestCoroutineScheduler

Where to read more