Agility with Legacy Code
Getting control of a Legacy codebase
It's hard to get going with agile if your codebase is not designed well and has poor automated test coverage. It's not easy to simultaneously improve the code quality and test coverage while at the same time continuing to deliver functionality. There's a human aspect as well, all the developers need to prioritize keeping the codebase clean, and continuing to improve test coverage.
Bache Consulting can help you if you find yourself in this situation. We offer a "Clean Code Seminar" which is designed to provoke some important issues for discussion within the development teams. We also offer "Coding Dojo" training sessions for teams wanting to learn Test Driven Development. In addition, we offer coaching and training in "Text-Based Approval Testing", a technique that is well suited to getting legacy code under test.
Text-Based Approval Testing
It is not usually all that easy to start writing classic unit tests for existing code that was not designed with testability in mind. JUnit et al require the code to be divided into isolatable units that can be tested individually. Much legacy code just isn’t designed this way, making it difficult to improve test coverage without doing risky refactorings first.
In this situation I’d often recommend starting with Approval Testing in order to get basic automated test coverage while you refactor the design to enable finer granularity unit tests. It’s a technique suited to almost any language and platform, for example C/C++ and Java. All that is required is that you can drive your system via the command line, (or certain rich client GUIs - see “StoryText”), and convert the output to some form of plain text.
Text-Based Approval Testing is a simple idea, which is to scale a common technique from unit testing to a whole program. You’re probably familiar with tests containing statements like AssertEquals(String expected, String actual). Text-Based Approval tests are similar, but for larger strings produced by whole programs. You save the "expected" string from the actual output of the program as a “golden copy”, which you compare against the “actual” output when you run the program again. This test will pass so long as the program output doesn’t differ from the golden copy. If it does, the test fails, and you view the differences. You can then either fix the program, or update the golden copy.
This tool is designed to help you write readable, robust, agile automated tests for rich-client applications built with Eclipse Rich-Client Platform or Java Swing. For more information see the TextTest website I'm one of the early-adpoter users of this tool, and I'd be more than happy to demo it for you.
Coaching & Training
If you are working with legacy code and need help getting it under test in order to become more agile, I’d normally recommend Text-Based Approval Testing. I’d be happy to come and talk to you about what that means in practice, and help you get going with some training and coaching. Please download a flyer with more information about what I offer.