Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Unit/Regression Testing  (Read 442 times)

Fuzzy

  • Bay Watcher
    • View Profile
Unit/Regression Testing
« on: December 16, 2008, 05:29:59 pm »

Less of a feature request, more of a suggestion, but I was reading through the DevNow log and its amusing quotes about flash-boiling bronze in the carts and remembering some of the other memorable ToadyOne quotes about sudden unexpected bugs after a change and it got me to thinking with my Software Engineering hat on (I got my masters in it from Carnegie Mellon, found I actually didn't want to pursure that line of work, but have kept my hand in keeping up with advances). This may or may not be feasible depending on how the code is set up, but a lot of time and trouble might be saved by setting up a unit/regression test suite with something like CPP Unit.

Basically, for the cost of writing the tests (which can be a small fraction of time spent originally coding), you can write tests to run every time you make a change, to check all of the common scenarios as well as situations that have caused bugs in the past. A well-tuned suite can take seconds to run and therefore can be run with every compile. It may not catch some of the more complex interaction bugs, but it does quickly tell you whether you're getting out what you expect for the given input. You can either devise your unit tests after coding, or build them along with the code (which has the additional benefit that when things are just being built and are simple, the tests are just as simple. As things get complex and interacting, so do the tests).

Ultimately, it's up to the ToadyOne as to whether this is worthwhile, but it is a thought. It might mean fewer hilarious episodes involving releases where ice falls up and a deconstructed floodgate floods the world, but it also may speed up development by eliminating the "where in the last 12 hours of coding did I introduce that bug?" blues.
Logged

Granite26

  • Bay Watcher
    • View Profile
Re: Unit/Regression Testing
« Reply #1 on: December 17, 2008, 09:15:10 am »

I think the issue here is that it would be hard to write a generic 'success' condition for a unit test in a simulation.   AKA there's no 'right' answer to a lot of the stuff.  May be helpful around some of the low end physics models things though...