~/talk

Test Doubles are Not To Be Mocked

Talkat RubyConf 2016 · 2016-11-10..11-12· [testing]
slides:none on file

Claim: test doubles (mocks/spies) reveal assumptions rather than inherently breaking tests. Example: a price calculator test either creates two Active Record tickets and a discount (two $20 tickets minus $25 = $30) or uses spies that assert a ticket#price_check call. Rails and Active Record make isolation painful; external APIs like Stripe belong behind stubs. Tests get judged by SWIFT and using verified doubles plus at least one end‑to‑end integration test proves the pieces actually work together.

AI-written summary · about

  1. 0:00Intro
  2. 1:03This is the talk about test doubles
  3. 1:52book
  4. 9:27Long term priorities might be different
  5. 9:47A A good test Leads
  6. 10:08Behavior validation
  7. 10:40A Tale of Two Tests
  8. 13:25State: uses real objects, expectation on state Spy : uses test doubles, expectations on behavior
  9. 16:04The code can be wrong and the double test will
  10. 16:28This is a matter of perspective
  11. 17:52The test can fail even though the test is right
  12. 18:26Design goal: A failure state causes exactly one test to fail
  13. 19:00Doubles test the design and the behavior
  14. 20:11The double encourages the creation of additional tests
  15. 20:57It encourages good design practices
  16. 21:41The design might change
  17. 22:43More isolation that many people are comfortable committing to up front
  18. 23:41Test doubles are design canaries
  19. 24:36Lot of setup might mean poorly factored design
  20. 26:02This level of isolation is hard on a team if you are the only one who cares
  21. 27:55A third-party framework can make this hard
  22. 29:18I was unwilling or unable to make the code isolated enough to keep the spies
  23. 30:33Conway's law applies to tests
  24. 31:17Think about what will make your tests fail
  25. 32:04Try writing Rails tests with isolation
  26. 32:35Using an integration test can force additional unit tests
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 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
?
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.