~/talk

Why You Don't Get Mock Objects

Talkat RubyConf 2011 · 2011-09-29..10-01· [testing]
links:none on file
slides:none on file

Mocks assert messages between objects not internal state, so use them in object‑oriented, tell‑don’t‑ask designs rather than procedural code. Example: replace a real ticket reserve system with a mock request handler and assert it should receive reserve with 55 when submit is pressed. Follow concrete rules: mock roles not objects, only mock types you own — don’t mock external APIs or internals; test boundaries with integration or acceptance tests. Read Growing Object‑Oriented Software Guided by Tests for the patterns.

AI-written summary · about

  1. 0:00Introduction
  2. 1:13I Am A Secondary
  3. 3:07Mock Objects Have Been Called
  4. 5:51The Tests Fail
  5. 7:28Procedural Programming
  6. 7:52Mocks Assert On Messages
  7. 9:01Key Idea In OOP
  8. 9:26The big idea is "messaging" -- that is what the kernal of Smalltalk/Squeak is all about... The key in making great and growable systems is much more to design how its modules communicate rather than what their internal behaviors should be.
  9. 10:53(Contrived) Example
  10. 12:34What Would The Code For The Interface Look Like?
  11. 13:14Notice Two Things
  12. 19:10Key Mocking Rules
  13. 19:28Mock Roles, Not Objects
  14. 19:44Wanting To Mock Concrete Objects Is A Design Smell
  15. 21:27When Mocking Roles, TDD Becomes A Design Process
  16. 25:56Instead Of Mocking A Role, Your Mocking An Implementation
  17. 26:08Duplicating Your Production Code In Your Test Is A Test Smell
  18. 27:29What Should We Do?
  19. 27:55Implement The Display Object Using Puts
  20. 28:54What About Testing The Display Object?
  21. 29:40Integration Tests / Acceptance Tests
  22. 30:26Only Mock Peers, Not Internals
  23. 31:33Key Question
  24. 32:47Different Types Of Messages Come In
  25. 35:23Internal Object
  26. 35:40It's An Implementation Detail
  27. 36:12Further Resources
~/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.