Tuesday, September 16, 2008

Re-Developing an Application using TDD against an Establised API

The last few months have provided an interesting experiment to test our application testing. For several reasons that I won't go into, we decided to rebuild one of our web services, and we made the decision to try and keep as many of the tests we had as possible. We found out quite quickly that moving unit tests to a new project when you're redesigning a system just isn't feasible. Our unit tests were too tightly tied to the design (well, that's the point of test driven design right?). However, our acceptance tests which tests our API as a black box was a perfect candidate to measure our progress.

It turned out to be more useful then we'd realised. When you have working black box tests, you can do whatever you want to the internals of the application as you already have appropriate tests to validate the application. This is exactly what we did.

We could happily start turning on our acceptance tests as and when we felt a feature was implemented. By insisting that we should not change these tests, it gives a an excellent benchmark for completeness. Of course, this is quite a rare occurrence, but it goes to show that if you test at different layers of your application and regard APIs or interfaces as unchangeable, you can re-implement to your hearts content.

No comments: