Mutant World

Wednesday, May 31, 2006

TestNG and Maven

I've been working with JDK 5, and some time ago I decided to try TestNG as test framework, leaving back JUnit.

Since then, I got addicted to TestNG, and if possible, will never go back to JUnit, as really TestNG is leaps beyond JUnit.

Now I am working also on a JDK 1.4 application that I build using Maven.
I've been really impressed by the fact that Maven supports TestNG out of the box, even in JDK 1.4 (using Javadoc annotations). Well, time to convert all tests from JUnit to TestNG, and it's very easy:

Before:

public class MyTest extends junit.framework.TestCase
{
public void testSomething() throws Exception
{
assertTrue(true);
}
}


After:

public class MyTest
{
/**
* @testng.test
*/
public void testSomething() throws Exception
{
assert true;
}
}


Plus, you get all cool TestNG features:

  • configurable advice methods (that run before/after the suite, the groups, the class, the test)

  • configurable dependencies among tests

  • configurable number of runs

  • configurable parameters to pass to the test

  • ...and much more

1 Comments:

  • Hi,

    Apologies for using your blog comment for attention, but I'm a bit stuck for other ideas.

    I'm trying to get some usage information on the SLP module within livetribe - I'd ask on the mailing list but the subscription page is failing.

    Could you drop me an email at koalaboy@gmail.com so we can talk some more about it ?

    (You can delete this comment)

    Thanks,

    Michael.

    By Anonymous Michael, at 21 June, 2006 16:06  

Post a Comment

<< Home