23 May 2008

Unit Tests & XP

Back from the fun at NEAF, I'm back to the usual routine. Lately I've been making some fundamental low-level changes so I'm writing unit tests to keep things under control. Following the eXtreme Programming paradigm entirely really doesn't make sense to me, but using it in select areas does.

Case in point: I have a class for an equatorial coordinate position, including computing star atlas chart cross-references. Writing tests that make sure the correct chart reference is computed is pretty straightforward and allows testing along chart boundaries. On the other hand, the class has a couple dozen methods so writing tests for the really mundane methods (e.g., copy constructors) is a little torturous. Further, some of these methods have been around for north of a dozen years, so I have a good comfort level with them.

While at NEAF, I mentioned unit testing to Steve Bisque. He said he doesn't use them. I told him they can take as much time to write as the code under test. I think that sealed the deal for him - no time for all that. Ultimately we as programmers need to be aware of unit testing and what it can do for our products, but the extent of their use really depends on schedules and other testing procedures in place for the product. I suspect that Software Bisque has a pretty solid system test procedure, so I guess they cover QA that way.

For me, using unit testing judiciously is the way to go. It gives some assurance for the low level stuff while system testing addresses the higher level. System tests are presently done with a combination of manual testing, Python scripts, and a test team (in that order.)

PS, in the true story category:
I once interviewed a young man for a programming position with my employer. The interview process placed the interviewee at a conference table with 3 staff programmers for what we called "the inquisition". The guy told us that he had never written code with a bug in it. There was a pause as we shot glances of astonishment around the table, and we politely continued the interview for about 20 more minutes. The guy had absolutely no chance of getting the job after that. If you've ever written a program, I bet you're laughing - loudly...