The Deep Synergy Between Testability and Good Design

Published December 13th, 2010 Under Functional Testing | 2 Comments

Many people moan about it the fact that their code is hard to test. They hack their code to make it testable and then they moan some more about how unit testing is an irritant, it makes code ugly. The fact of the matter is, it isn’t true. There’s a deep synergy between testability and good design. All of the pain that we feel when writing unit tests points at underlying design problems. In this session, Michael Feathers will, through a series of examples, show how you can use testability challenges to reconsider and improve your design.

Producer: Norwegian Developer Conference 2010

Related Videos:


Comments

Name (required)

Email (required)

Website

Speak your mind

*

2 Comments so far

  1. gregory on December 18, 2010 17:03

    C++ has friend which makes creating testing frameworks a lot easier.

  2. Michael on December 20, 2010 10:44

    Interesting thoughts on Dependency Injection frameworks.

    It sparked a few thoughts:

    * DI Frameworks allow you to create these huge object graphs without realizing that you _have_ to create these huge object graphs to instantiate some objects. This is rather painful for testing, as you know.

    * Regarding “the plan” vs “the bag of parts,” lately I’ve been putting the object graph creation into code in various parts and then calling that from the DI framework. I think this good if small step in the right direction of making the plan explicit.

    * Perhaps the best (only?) reason to use DI is to swap in a mock for something that does IO.

    * I especially dislike when people misinterpret “Code to the abstraction” as “Code to the interface” and then make interfaces for everything.