Thursday, December 23, 2004

Test first. Code later.

It has taken generations for this simple, brilliant idea to take hold in this industry. As a relatively recent convert to TDD I can attest (sorry) to the power this simple idea encapsulates.

I do a lot of work in the Java ecosystem. Two words spring to mind - actually three. Confidence, documentation and Jython.

Confidence : TDD raises your confidence level in your software. Every step of the way your have a full test suite. Every step of the way you have a mechanism for catching the knock-on effects that accompany even the smallest change in source code. TDD has saved my life so many times...

Documentation : "Read the source, Luke" has been joined by a less daunting epiteth : "Read the tests, Luke". Test scripts are a great source of real documentation for how objects/methods/apis/interfaces are to be used and not to be used. When the Javadoc fails you, hit the tests.

Jython : Anybody coding in a statically compiled programming language that is not using a dynamically typed programming language for the tests, has missed a golden opportunity for a productivity leap. In the C world, CPython. In the .NET world, IronPython. In the Java world, Jython.

Jython has quietly carved out a niche for itself in the testing area. Some examples:

  • Write Eclipse JUnit Tests in Jython - this is a recently published article about unit testing with Jython but there are tons more. Google is your friend.

  • PushToTest is an Open Source test automation system that uses Jython

  • Grinder provides a load testing framework for executing
    Jython scripts across many threads, processes and machines; and allows
    the whole shebang to be controlled from a graphical console.

No comments: