Motley says: "If-then-else hooks are the best way to inject mock objects"

Summary   Motley:  A simple if-then-else hook is the simplest and best way to inject a mock object.   Maven: First, you have to design to interfaces. Then, techniques like dependency injection, factories, and endo-testing are more effective ways to inject mock objects. ______________________________   [Context:  Maven and Motley continue a discussion on mock objects….

12

Motley says: "The only thing I’m going to mock is you"

Summary   Motley:  I can’t mock something that I have no control over (like third-party or old legacy code)   Maven: Design to interfaces, create a wrapper, and use tools for mocking. These are all great practices for leveraging mock objects. ______________________________   [Context:  Motley is struggling with creating mock objects for his unit tests]…

6

Motley says: "Unit tests take too long to execute, so don’t bother"

  Summary   Motley: Unit tests take too long to execute. I’m not going to bother.   Maven: Unit tests need to run quickly – you need to execute them frequently. Mock objects can help. ______________________________   [Context: Motley has been writing unit tests for a couple of days, but is not sold on developers…

2