Monday, November 3, 2008
One of the best ways to ensure testable code is practice Test Driven Development. How can code not be testable if it is already tested?
Another good idea is to write code that is easy to test in isolation, which is mostly done by mocking its dependencies. "Mockable" classes are achieved with:
- Injecting dependencies with an Inversion of Control framework such as Spring
- Avoiding singleton and static methods
- Favoring composition over inheritance
Subscribe to Posts [Atom]