Mocks
Big Idea: Interaction, Not State
FakeTransactionLog
's little buffers, we asserted on its state.But how were those buffers filled? Ahhhhhh, yes: they record the history of how DepositAction
interacted with FakeTransactionLog
.DepositAction
may have some state, but in this case we care about (and assert on) its interactions.A mock is the ideal tool when we care about an object's interactions: which methods were called, what parameters were passed,
and so on.
Mock objects check the interaction between collaborating objects.
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |