Thursday, September 01, 2005

Unit Tests II

Our current project is approaching delivery. As you would expect when the word "release" is uttered, the bugs start wriggling to the surface. I just wasted some time trying to figure out a page that is supposed to display current and future data, but not data that is historical.

The issue was that an item with a date in the year 2009 was getting filtered out as historical. The isHistory method was written ages back and, naturally enough, was covered by unit tests. So how could it be wrong?

Well, firstly, the unit tests checked past and current dates, but never a date in the future. Worse, one of the tests was checking the wrong thing. Ouch. Now I'm in a quandry. If I fix this method, my code will work, but how many other places will be broken. Thankfully, Eclipse has a References search. The answer came back that only my code was using this method (maybe other had found the bug and avoided it?). I fixed the unit tests, the code defective method and verified that the missing data did appear.

Unit tests are good. Just don't believe they are always right. Murphy's law applies, as always.

[Comments turned off and comment spam removed: 5/Sep/2005]
Category: Software, Programming, Java, Unit Tests

0 Comments:

<< Home