← Graph

Don't test randomness — understand, extract, control it

takeaway 2 connections

Rodzik's closing prescription for testing non-deterministic code: don't try to test randomness directly. Instead understand where the randomness lives, extract it behind an abstraction (like the `Dice` interface), and control it in tests via a fake or injected implementation. Applies equally to obvious `rand`/`Kernel#rand` calls and hidden ones like `Time.current`.

type
recommendation
takeaway Don't test randomness — understand, extract, control it
about
Closing example making the general principle concrete.
takeaway Don't test randomness — understand, extract, control it
from_talk
Closing prescription of the talk.

Provenance