Welcome to the Surface

May 26th, 2008 · 1 Comment ·

Last year I noticed that I could refactor a piece of code and make it better without actually knowing what the code does. This made me realize that the goodness of the code is independent of its function. I also realized that when I was looking at code to refactor I went thought a mental check-list of known red-flags and specific refactorings as an antidote to those red-flags.

So I had an idea to write a bytecode analysis tool which would identify the red-flags for me. The motivation was that it is hard to teach people how to write quality tests if the code base is not testable. One only learns how to write quality tests after one has written lots of tests. And it is hard to write a lot of tests if your code is hard to test. So I had an idea:

“Perhaps I can’t make developers to write tests, but perhaps I could prevent developer from getting into untestable mess by avoiding the red flags. This way even if they don’t write tests today, they could write tests tomorrow.”

The idea was to build the Testability-Explorer and then to integrate it into project’s continuous build so that whenever a developer tried to check in some hard to tests code the Testability-Explorer would flag the pieces of the code as hard to test and then fail the build. However, I wanted to make sure that the Testability-Explorer would not only fail the build but also give useful suggestions as to which lines of code are a problem and how to refactor them. Without this feedback the developers would only get frustrated, with the feedback the developers would learn why a particular way of coding is a problem, from a testing point of view. This way the code-base would always remain in easy to test state. And even if developers were not writing tests today, nothing would prevent them from writing the tests tomorrow.

Once we have built the Testability-Explorer we realized that we had a chance to change not just our developers but a whole open source community and the idea of http://TestabilityExplorer.org the web site was born. Here we publish the testability reports for most major Java open-source projects. We hope that this tool will be a flashlight into which open-source projects are doing a great job and should get recognized for their hard work and also we hope that we can offer suggestions on how to refactor those projects which are less then ideal from unit-testing point of view.

– by Miško Hevery

Tags: Testability Explorer

1 response so far ↓

  • Lukas // Dec 17, 2009 at 7:36 am

    maybe you know something similar for C# ?
    I would be very interested to run testability analysis tool on my code.

Leave a Comment