Michael Feathers, author of the book “Working Effectively with Legacy Code”, gave a presentation at SD West in 2007 about designing an API with consideration for how it will be unit tested. He presents recommendations such as avoiding static methods and avoiding final/non-virtual methods (although I disagree with the latter recommendation in my book, where I argue that being minimally complete is more important). He also presents a golden rule of API Design: “It’s not enough to write tests for an API you develop, you have to write unit tests for code that uses your API.” He also states that you should supply your tests to your users. I could not agree with those statements more!
Comments are closed.