| The Declarer (Floyd McWilliams' Blog) |
|
Mostly political; some random geekery.
Floyd McWilliams' home page
Weblog Links -- Hover for Description
Ace of Spades
Baseball Blogs:
Baseball Musings
6-4-2
Online Publications:
The New York Press
Usenet: James Donald's recent Usenet posts.
|
Friday, August 22, 2003
JUnit is the standard Java unit testing tool. That fact is quite an indictment of the current state of software testing: JUnit is a horrid hack that anyone could slap together in about three days.
Here is how JUnit works: You write a class containing methods whose names begin with "test". Inside those methods, you write code that you would like to test. The tests consists of assertions about the code's state. Here is an example from a test I am working on today:
JUnit thus approaches life like Mel Gibson in Lethal Weapon: With a gun in its mouth, threatening to commit suicide if your test is not in order. When a mismatch in an assertion is found, JUnit shows only the difference in expected and actual values. JUnit has access to all kinds of data passed to its assertion methods, but apparently it's important for JUnit to hide that information from you. Here is the test output that caused me to throw a tantrum on this blog: Well that's useful: I'm missing a space somewhere! Let's say that my expected and actual output were strings of several thousand characters that contained scores of spaces. Using JUnit I would know to quit my job, go home, and play Civilization III. (A note: I had to type JUnit's error message because the error messages are not copyable. Whether this is due to crappy JUnit design or crappy Swing design is left an an exercise to the knowledgable reader.)
|