~/talk

Testing Randomness

Talkat wroc_love.rb 2023 · 2023-09-15..09-17· [testing]
links:none on file
slides:none on file

A simple two-player dice game is implemented, then shown failing silently: tests that mirror code logic stay green but miss cases. The team builds a Dice abstraction, injects a fake dice into tests, and adds dependency injection so changing the real die (from 1–6 to 1,1,3,4,5,6) no longer breaks behavior tests. Tests become deterministic; adding event logs records each roll and the reason for the winner so bugs are reproducible. Time travel or injected current time is recommended for clock-driven code.

AI-written summary · about

  1. 0:00Introduction and story setup
  2. 1:56Starting the game implementation
  3. 3:01Writing initial tests and code
  4. 5:13Adding draw condition to the game
  5. 8:07Fixing flawed test logic
  6. 9:17Using stubs for deterministic tests
  7. 11:48Introducing the better dice
  8. 12:54Refactoring with dependency injection
  9. 16:37Creating a fake dice for testing
  10. 19:50Dependency injection in practice
  11. 21:15Customer complaint reveals flaw
  12. 22:18Adding game event logging
  13. 24:51Analyzing test flaws and fixes
  14. 25:13Problems with logic in tests
  15. 27:23Stubs and mocks pros and cons
  16. 30:17When to use mocks and stubs
  17. 30:39Dependency injection in tests
  18. 31:41Instance doubles and team acceptance
  19. 32:45Challenges with fake implementations
  20. 33:47Logging and auditing in tests
  21. 35:54Testing randomness without testing randomness
  22. 37:22Time travel for testing time-dependent code
  23. 38:09Q&A on testing time and randomness
  24. 39:15Keeping test doubles in production code
  25. 40:41Ensuring fake and real implementations align
  26. 42:08Team ownership of test doubles
  27. 43:31Final Q&A and closing remarks
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.