JUnit: A critical look
By Angsuman Chakraborty, Gaea News NetworkTuesday, August 10, 2004
Having said that I still think JUnit is serving its purpose well and is pretty robust so long you stick to the well trodden path.
ARTICLE CONTINUED BELOWTo comment on the comments:
> I expect that TestSuite() overrides countTestCases() appropriately… but the framework is not written to prevent people from abusing it, since that would get in the way of people who need to extend it for legitimate reasons.
It returns 1. In fact I don’t see any purpose of the method other than to abuse it! Any other return value is wrong for the method. It definitely wasn’t properly unit tested.
Thanks for the suggestion on TestNG (NG = New Generation?).
It looks better, though I am a bit uneasy about using annotations to define a test.
It apparently supports grouping of tests which is a big plus.
I will take a closer look at it.
> though there is a Smalltalk flavor to it that someone who came to Java from other languages would not appreciate.
Not being from smalltalk I am surely interested to know what that flavor is. Can you please elucidate?
My background was C++, before Java.
|
August 11, 2004: 4:57 am
“their user stories didn’t foresee it” — that’s it. Kent Beck’s JUnit was written to certain (probably not documented) specifications and assumptions. It actually works well for its intended purposes, though there is a Smalltalk flavor to it that someone who came to Java from other languages would not appreciate. I expect that TestSuite() overrides countTestCases() appropriately… but the framework is not written to prevent people from abusing it, since that would get in the way of people who need to extend it for legitimate reasons. I suspect that “TestResults” is following the Smalltalk idiom of a “collecting parameter” (see Kent Beck’s book “Smalltalk Best Practice Patterns”. |
|
x |
|
August 10, 2004: 11:28 am
The design assumes you implement Test, and that’s all. However, it provides _convenience_ methods (such as TestCase) that allow you to write Tests with a minimum of fuss. Yes, it’s not overly defensive: it makes the assumption that the developer is trying to use it, not abuse it. If you look at the lifecycle of the tests, BTW, you’ll see why the run method is passed back and forth. |
|
x |
keith ray