by Miško Hevery Shahar asks an excellent question about how to deal with frameworks which we use in our projects, but which were not written with testability in mind. Hi Misko, First I would like to thank you for the “Guide to Writing Testable Code”, which really helped me to think about better ways to [...]
Entries Tagged as 'Testability'
Interfacing with hard-to-test third-party code
January 4th, 2009 · 7 Comments
Tags: Advice · Testability
Static Methods are Death to Testability
December 15th, 2008 · 55 Comments
by Miško Hevery Recently many of you, after reading Guide to Testability, wrote to telling me there is nothing wrong with static methods. After all what can be easier to test than Math.abs()! And Math.abs() is static method! If abs() was on instance method, one would have to instantiate the object first, and that may prove [...]
Tags: OO · Rant · Testability
My Unified Theory of Bugs
November 17th, 2008 · 10 Comments
by Miško Hevery I think of bugs as being classified into three fundamental kinds of bugs. Logical: Logical bug is the most common and classical “bug.” This is your “if”s, “loop”s, and other logic in your code. It is by far the most common kind of bug in an application. (Think: it does the wrong [...]
Tags: Advice · Testability
Testability Explorer: Measuring Testability
October 21st, 2008 · 4 Comments
Testability Explorer: Using Byte-Code Analysis to Engineer Lasting Social Changes in an Organization’s Software Development Process. (Or How to Get Developers to Write Testable Code) Presented at 2008 OOPSLA by Miško Hevery a Best Practices Coach @ Google Abstract Testability Explorer is an open-source tool that identifies hard-to-test Java code. Testability Explorer provides a repeatable [...]
Tags: Advice · OO · Testability · Testability Explorer
Dependency Injection Myth: Reference Passing
October 21st, 2008 · 31 Comments
by Miško Hevery After reading the article on Singletons (the design anti-pattern) and how they are really global variables and dependency injection suggestion to simply pass in the reference to the singleton in a constructor (instead of looking them up in global state), many people incorrectly concluded that now they will have to pass the [...]
Tags: Advice · OO · Testability
To “new” or not to “new”…
September 30th, 2008 · 24 Comments
by Miško Hevery Dependency injection asks us to separate the new operators from the application logic. This separation forces your code to have factories which are responsible for wiring your application together. However, better than writing factories, we want to use automatic dependency injection such as GUICE to do the wiring for us. But can [...]
Tags: Advice · Testability
Where Have all the “new” Operators Gone?
September 10th, 2008 · 7 Comments
(the other title: Your Application has a Wiring Problem) In My main() Method Is Better Than Yours we looked into what a main() method should look like. There we introduced a clear separation between (1) the responsibility of constructing the object graph and (2) the responsibility of running the application. The reason that this separation [...]
Tags: Advice · OO · Testability
My main() Method Is Better Than Yours
August 29th, 2008 · 7 Comments
By Miško Hevery People are good at turning concrete examples into generalization. The other way around, it does not work so well. So when I write about general concepts it is hard for people to know how to translate the general concept into concrete code. To remedy this I will try to show few examples [...]
Tags: Advice · Rant · Testability
Root Cause of Singletons
August 25th, 2008 · 38 Comments
Since I have gotten lots of love/hate mail on the Singletons are Pathological Liars and Where Have All the Singletons Gone I feel obliged to to do some root cause analysis. Lets get the definition right. There is Singleton the design pattern (Notice the capital “S” as in name of something) and there is a [...]
Tags: Advice · Rant · Testability
Where Have All the Singletons Gone?
August 21st, 2008 · 24 Comments
by Miško Hevery In Singletons are Pathological Liars we discussed the problems of having singletons in your code. Let’s build on that and answer the question “If I don’t have singletons how do I ensure there is only one instance of X and how do I get X to all of the places it is [...]
Tags: Advice · OO · Rant · Testability