Misko Hevery

Recent site activity

Blog Entries‎ > ‎

Java is Naturally Untestable?

posted ‎‎May 18, 2008 11:27 AM‎‎ by Misko Hevery   [ updated ‎‎May 18, 2008 4:57 PM‎‎ ]
So I got blogged again. :-) http://blog.thinkrelevance.com/2008/5/18/java-is-naturally-untestable But I can't say I agree with the "Team Relevance" guys.


I don’t see how your choice of language effects testability. Dynamic languages allow you to reach in and change the definition of any method at runtime. Dynamic languages fans suggest that as a result, testability practices such as Dependency Injection are not relevant and that dynamic language is inherently more testable. However code is global state and you reaching in and changing the global state produces all the same problems as global state in Java except worse since you are not only changing global state of data but also global state of code. So I simply don’t buy this argument. To me changing the definition of method at runtime falls into the same level of testability as subclassing in tests and overriding a method. TDD fans frown on this practice, for good reason, but it is no different then changing method definition at runtime. Dynamic languages are more terse which is a great plus, but I don’t see how you can build a large scale many developer codebase out of dynamic languages. Static typing is wordy but it is a level of information which is very useful in large many team projects. So everything needs to be weight in proportion.