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: "Refactoring means no more up-front design"

Summary   Motley:  Refactoring keeps my design clean from the start, so no more up-front design!   Maven: Up-front design is still necessary to achieve clarity on the overall approach (preventing rework later) and needs to be documented to allow others to review your thinking. ______________________________   [Context:  Motley is trying to educating himself on…

2

Motley says: "Test both private and public methods"

Summary   Motley: To get high code coverage, we should be testing both public and private methods   Maven: Only test public methods. Testing private methods gets in the way of refactoring ______________________________   [Context:  Maven checks in on Motley’s unit testing practices and notices something odd]   Maven: Hey Mot – how is the…

6

Motley says: "I don’t have time to Refactor – I need to get it right the first time"

  Summary   Motley: Refactoring takes too much time – I have to ship you know!   Maven: Refactoring leads to much more maintainable code, and if you have tests in place, the return on investment far outweighs the cost. ______________________________   [Context: Motley has just embarked on his first adventures with TDD, but Maven…

2

Motley says: "If I write code to pass tests I’m cheating!"

  Summary   Motley: Tests need to validate code that has already been written – not the other way around.   Maven: Writing tests before you code allows the tests to drive your code while providing more sound requirements validation. ______________________________   [Context: Motley is thinking through test-driven development before he goes off and tries…

3

Motley says: "I can’t write tests before application code – there’s nothing to test."

Summary   Motley: You can’t possibly write tests before code – there’s nothing to test.   Maven: Writing tests for a method before coding it has all kinds of design advantages. ______________________________   [Context: Motley has been writing unit tests for a week. Maven wants to take the next step]   Maven: Hey. Looks like…

0