Testability-explorer is a tool which analyzes java byte-codes and computes how difficult it will be to write unit-test. It attempts to help you quantitatively determine how hard your code is to test and, where to focus to make it more testable.
Test metric tool can be used:
1. As a learning tool which flags causes of hard to test code with detailed breakdown of reasons.
2. To identify hard to test hair-balls in legacy code.
3. As part of your code analysis-toolset.
4. As a tool which can be added into continuous integration that can enforce testable code.
TestabilityExplorer.org records the testability scores for many open source and commercial Java libraries.
The compiled bytecode for the library is analyzed and metrics are calculated for the testability of individual classes. Those classes fall into one of three categories - 'excellent', 'good' and 'needs work'. Generally speaking, injectability, mockabiliy and composition are good, and static state is bad. Figures are recursively calculated, but only inside the jar in question.
The metrics are a calculation of the skill of the development team in making their classes testable. You cannot use these metrics to say that Tomcat is better than Jetty or vice versa, as the features of each are not taken into account. These metrics will also not tell you whether a particular library will be easy to use or not. It just tells you how dedicated the development team was to making testable software. As we track the changing figures overtime, we can see whether the team in question was dedicated to improvement or not.
In what I hope will be the first of several articles about Guice, a new lightweight dependency injection container from Bob Lee and Kevin Bourillion from Google, this article examines the simplest and most obvious use case for the Guice container, for mocking or faking objects in unit tests. In future articles I will examine other, more ambitious areas where it can be used, including dependency elimination in large code bases.