What is simpler than writing a JUnit test? Getting someone else to write them for you! The really nice people at Agitar Software have developed a couple of tools as part of their “No Java Class Left Behind” programme, that will write JUnit tests for your existing code to prove that it works as expected. This sort of testing is known as characterization testing, and is useful if someone gives you a big steamy pile of untested code that you have to make sure won’t break when you start refactoring it (I have a great story about that, but you need to buy me a beer first).
They have a commercial product called AgitarOne that is worth checking out, which runs on your intranet and you can do a whole bunch of stuff in, but they also have a free version called JUnit Factory. You can either upload your code to them via your browser or via an Eclipse plugin. Code In, Tests Out! Superb!
It’s not a substitute for development time testing, but still a great tool for your professional arsenal. How cool will you look when you put a test suite around that nonsense you have been given to work against 😉
There’s a great interview with Alberto Savoia from Agitar on the Business of Software conference site that goes into the how’s and why’s.