Test Infected

I've been playing with linking Prevayler and WebWork together in the "next generation" of a website I'm working on (occasionally persisting to a database so the data is easy to use by other programs) I thought that it was going well.

The key word there is "thought" After doing a little browsing of the current app, I noticed that some data just wasn't being persisted properly. No problem, the XP crowd shout, just write a unit test that displays the bug and then write just enough code to make it pass. It's only now that the wisdom of those words, which I always appreciated on an intellectual level, sinks further into my programming mind.

Of course, looking on the bright side of this current exercise, I'm going to be left with a trail of tests that document not only the system, but what I've done to fix it, including how I got there. In addition, there'll be a safety net ready for the next time I bug surfaces. And I get the challenge of rooting through the code, cleaning it up and generally making the world a brighter place.

Yeah, test infected makes a lot of sense.


Simon Stewart on Thursday, 06 February, 2003

Posted in: /java

You may comment...



Added by Steve Conover on Thursday, 06 February, 2003

I think it really shines when you actually write tests first. Then it's not an exercise that requires discipline - you write a test that breaks, which expresses some part of a use case, then do the simplest things that works to get your test running, then refactor. But the main point is your tests give your code permission to exist. Anything that doesn't have permission, you delete.

I'm using the same architecture on one of my projects...for functional testing, take a look at jWebUnit - http://jwebunit.sourceforge.net/ - basically a more compact and concise HttpUnit.

Good luck. -Steve

Categories