frozen time
Making the current time a fixed value during a test, by passing an instant in or patching the clock.
In more detail
With the clock held still you can check both sides of a boundary, such as one second before expiry and exactly at expiry, with no sleeping and no race. Libraries such as time-machine and freezegun patch the clock globally; a parameter is narrower.
Related terms
- wall clock — The computer's real current time, which keeps moving while a program or test runs.
- datetime — The Python standard-library module and type that represent a date and time of day.
- seam — A place in the code where you can swap in different behaviour without editing the code itself, such as a parameter.
- deterministic — Always producing the same result from the same inputs, with nothing left to chance or timing.
Taught in
- Testing Time And Randomness — Automated Testing, TDD & Quality Engineering
- Flaky Tests And How To Kill Them — Automated Testing, TDD & Quality Engineering