Deterministic Test
Pronunciationdih-TER-mih-NIS-tik test
Definition
A deterministic test gives the same result every time it runs, because nothing random, time-based or order-dependent can change the outcome.
Where you hear it
In discussions of flaky tests, CI reliability, and when tests use dates, random numbers or the network.
Examples
Freeze the clock so the test is deterministic.
Seed the random generator in the test.
The test fixes the random seed, so it gives the same result on every run.
Common mistake
Using today's date or a real network call inside a test. It passes today and fails tomorrow.
Don't confuse with
A flaky test, which is the unwanted result when a test is not deterministic.
Say it at work
- In a meeting or chat
Make it deterministic before you merge.
- In an email or ticket
The failure only happens on some runs, so it's not deterministic.
Keep exploring
More in Testing & Quality