Testable Java Design

February 17, 2012

Issues with testability boil down to our inability to write tests or the excess trouble we have to go through to get it done. The article “Guidelines for Java Testable Design” is excerpted from the Unit Testing in Java book by Lasse Koskela. In this extract shares a set of dos and don’ts for testable design and recommends to avoid complex private methods, static methods, logic in constructors and to favor composition over inheritance. He also suggests to treat the new keyword with care because it essentially hardcodes an implementation we cannot substitute.


%d bloggers like this: