When asked about automated unit testing in Java, most developers first think of JUnit. Without a doubt, JUnit is still the de facto standard when it comes to test-driven development in Java, and is arguably the most popular/successful in the xUnit family of frameworks created by Kent Beck, and (in case of jUnit) Erich Gamma, the co-author of the very influential Design Patterns book (one of GoF).
Yet, despite all the popularity and the success behind jUnit, the open source community chose to embrace yet another automated testing framework for Java called TestNG. Created by Cédric Beust and Alexandru Popescu in 2004, TestNG tries to address many of the shortcomings of jUnit outlined here and here.
Of course, the jUnit camp has not stood still since 2004, and it caught up to TestNG with many of the features introduced in version 4.0, most notably the annotation-based API. Yet, TestNG is still considered superior to jUnit is the areas of flexibility, configuration-driven-testing, dependency-driven-testing, reusability of test cases through parameters, and efficient/quick rerunning of failed and skipped tests. Also, TestNG is not just limited to unit-testing, since it can also serve well as an all-around testing framework for integration and system testing.
For those with a significant investment in jUnit, TestNG folks even provide a simple Java utility to help with the migration from jUnit.
Filippo Diotalevi from IBM wrote a great TestNG example that outlines some of the main principles behind the framework as well as the @Test, @Before, @After annotation syntax that is at the heart of TestNG. It's a great read.
Update: if you live in the Bay Area, you can hear me talk about TestNG at the next event of The San Francisco Java Meetup on February 11th, 2008 at our classroom in the city. I hope to see you there!