I am very happy to announce the immediate availability of
TestNG 4.0
There are a lot of improvements and new features in this release, so we decided
to skip to a major version (actually, we considered calling it version 5, but it wouldn’t have been fair to JUnit ;-)).

The change log is included below, but I’d like to take this opportunity to
discuss one of the new features:  Data Providers.

TestNG lets you specify parameters to your test methods, and their values are
then defined in testng.xml.  This approach works fine in simple cases but
is not enough when:

  • You need to pass complex objects.
  • These parameters need some complex logic to be created.

Data Providers address these two problems and also let you specify as many
sets of parameters as you want, so that your test methods will be invoked
several times, each time with a different set of parameters.

Here is an example:

// This test method declares that its data should be supplied by the Data
// named "test1"
@Test(dataProvider = "test1")
public void verifyData1(String n1, Integer n2) {
  System.out.println(n1 + " " + n2);

// This method will provide data to any test method that declares that
its Data Provider
// is named "test1"
@DataProvider(name = "test1")
public Object[][] createData1() {
  return new Object[][] {
    new Object[] { "Cedric", new Integer(36) },
    new Object[] { "Anne", new Integer(37)},

This code will cause the method verifyData1() to be invoked twice,
once with "Cedric", 36 and then with "Anne", 37.

Of course, this data can come from more complex places, such as a file, a
database or the network.  Since the creation of the parameters is done in
Java, anything is possible.

This is a big release for the TestNG team, and it wouldn’t have been possible
without a lot of hard work from Alexandru Popescu and Hani Suleiman. 
Thanks guys!

TestNG 4.0 can be downloaded on http://testng.org
and the Eclipse plug-in has also been uploaded to the update site.  Here is
the change log:

Change log for TestNG 4.0


  • Fixed: suite methods now invoked only once in a hierarchy
  • Added: @DataProvider and @testng.data-provider
  • Fixed: Interleave order now respected for before/afterClass methods
  • Added: Can now invoke java -jar testng-4.0.jar <…>
  • Added: Support for BeanShell
  • Added: Method Selectors (IMethodSelector)
  • Fixed: In the absence of dependencies, @Configuration methods respect
  • Fixed: Bug in multithreaded dependencies on methods
  • Fixed: dependsOnGroups wasn’t working on regular expressions
  • Fixed: Bug in <package> when directories contain spaces in their names
  • Fixed: Introduced a JDK5 dependency in the JDK1.4 build (getEnclosingClass())
  • Fixed: Output directory in ant task was not honored if it didn’t exist
  • Fixed: Problem with timeout according to

Eclipse plug-in:

  • Fixed: Wasn’t handling linked directories correctly
  • Fixed: Bug in QuickFix implementation
  • Added: Quick Fix for JUnit conversion (Annotations and JavaDoc)
  • Fixed: Methods Run as TestNG test
  • Added: Package level Run as TestNG test
  • Fixed: Resources from the linked directories are using a wrong path when
  • passed to command line TestNG

IDEA plug-in:

  • Added: Support for JDK 1.4 (both projects and IDEA itself)
  • Fixed: Classes that contained only configuration were ignored