Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
1 reply Latest Post - ‏2006-11-22T03:37:40Z by SystemAdmin
SystemAdmin
SystemAdmin
210 Posts
ACCEPTED ANSWER

Pinned topic Unit testing - 'correct' idioms with Junit 3.8, JUnit 4 and TestNG

‏2006-11-14T00:26:34Z |
Hi,
I am trying to evaluate JUnit 4 and TestNG, and have built classes that use the backwards compatibility of each to enable the reuse of existing JUnit 3.8 style test helper classes, (they exercise equals/hashcode/serializable/comparable and accessors).

Although each testcase works, I'm not entirely happy I am 'doing it right'.

To illustrate the frameworks, I have a toy class under test, (Person), and a testcase for each framework. I've posted this code up here: http://javaunittest.pbwiki.com/
for discussion and correction by anyone and everyone.

Would anyone mind having a look over the code and suggesting improvements?, I'd be most grateful.

Additionally I have attached the source (TestSpikes.zip).

Regards,
Chris
Updated on 2006-11-22T03:37:40Z at 2006-11-22T03:37:40Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    210 Posts
    ACCEPTED ANSWER

    Re: Unit testing - 'correct' idioms with Junit 3.8, JUnit 4 and TestNG

    ‏2006-11-22T03:37:40Z  in response to SystemAdmin
    Chris-

    Couple of points for you regarding the TestNG test-- you don't need to place the @Test annotation on both the class and its tests-- I find it easy to place it only on the class itself unless I have specific attributes I'd like to apply to a particular method (like grouping, etc).

    Setting junit=true means that the test will be run just like a JUnit style test-- in which case you don't need to follow TestNG idioms-- just follow traditional JUnit style conventions and TestNG will run the test just like JUnit would.

    For more info on TestNG, see http://www.testng.org and Cedric Beust's blog at http://beust.com/weblog/.