Characterization tests provide a safety net for your legacy Java code by helping identify unintended changes in software behavior caused by code maintenance. JUnit Factory from Agitar Software may be used to automatically generate these tests for you. In this post, we’ll take a look at what happens to these characterization tests when a simple code change is made.
Archive for January, 2008
JUnit Factory is a free Eclipse plug-in from Agitar Software that generates characterization tests for your Java code. For more background on what characterization tests are, and how you use them, you’ll want read my post “Characterization Tests: How To Deal With Legacy Java Code”.
This article describes how to generate tests for a simple Java class and how to read the tests. Not all of your real code will be this simple, and not all generated tests will be this simple, either. But, bear with me as we start small and work our way up.
Companies have invested billions of dollars over the last decade building components and applications based on the Java framework. This work represents a wealth of expertise and collective knowledge that firms must protect and maintain. Unfortunately, in the dynamic field of software development where programmers change jobs, on average, every 18 months, the original developers on these past projects probably aren’t around anymore.
As a result, Java developers seldom have the luxury of working on true greenfield projects. Instead, they are faced with adding enhancements and fixing bugs on projects built upon a code base they didn’t write and don’t fully understand. How can developers safely make changes to legacy code without accidentally breaking something unrelated?
Characterization tests provide a safety net – a change detection engine – that identifies behavioral changes in legacy code in order to remedy regressions early in the development process. Fixing regressions early shortens development timelines, increases code quality, and allows a team to become more agile. You can automatically generate your team’s characterization tests using the free JUnit Factory for Java from Agitar Software.