Charles Miller reminds us that there are two
reasons for using mock objects.
- To create an environment where the object under test can live.
- To test that the object under test correctly modifies the environment.
Each use requires a slightly different API (#1 sytle APIs tend to be more
flexible than style #2). I’ve used both styles of APIs in the past
(and had been frustrated trying to use a style #2 API in a style #1
situation), but I hadn’t connected the differences with the reason
for the differences before.
|