Tuesday 4 August 2009

Hooray for Unit Testing

I'm faced with doing asome NPC's for a Battlestar Galactica campaign thats coming up in my local RPG group. Now the systems pretty similar to the Serenity one, both being different versions of the Cortex RPG system. The big difference is in Traits, which in serenity can be Minor or Major in Serenity now can be a Dice from D2 to D20.

For example :

"Allure (minor)" becomes "Allure (D2/D4)"
"Dead Broke (minor or major)" becomes "Broke (D4-D12)"


I've got an NPC program for Serenity which I wrote and evolved over two campaigns and I'm reworking that to work with Galactica. My Trait object's go from being having an enum of Major Minor and Both, to having a list of dice types. This just means removing a field and replacing it with a List, and correcting all the ensuing errors that occur, followed by some UI work. Nothing major.

But can I be sure that something subtle isn't broke, some small corner of the app that shall remain forever buggered? No, you never can be. But the unit testing coverage gives me a lot more confidence that I would have had without it. I'm not even through fixing all the errors but I know that the three major parts of the app that touch traits now work with the the dice list, and I haven't even run it yet.

Unit testing lowers refactoring time. Hooray for unit testing !

No comments: