I am a software engineer at Google on the Android project and the creator of the Java testing framework TestNG. When I'm not updating this weblog with various software-related posts or speaking at conferences, I am busy snowboarding, playing squash, tennis, golf or volleyball or scuba diving. Cedric is a DZone MVB and is not an employee of DZone and has posted 90 posts at DZone. You can read more from them at their website. View Full User Profile

Announcing TestNG 5.12

03.29.2010
| 5580 views |
  • submit to reddit

I’m happy to announce the release of TestNG 5.12.

The most important change is that JDK 1.4 and Javadoc annotations are no longer supported. If you are still using JDK 1.4, you will have to stick with TestNG 5.11.

The most notable new feature in this new release is the annotation @Listeners, which lets you add listeners directly in Java (no need for XML). Any TestNG listener (i.e. any class that extends ITestNGListener) can be used as a value for this annotation, except IAnnotationTransformer which needs to be known before TestNG starts parsing your annotations.

For example, suppose that one test class is failing and you want to share the full report with a coworker, you can use the EmailableReporter to generate a single HTML file that you can then email. All you need to do is add the following @Listeners annotation:

@Listeners(EmailableReporter.class)
public class VerifySampleTest {
// ...
}

and then run the class with TestNG, which will generate the following report:

I also made a few improvements to the Eclipse plug-in, such as a New File wizard:

You can download TestNG and the TestNG Eclipse plug-in at the usual places, and the new version will be available in the main Maven repository shortly. Here is the full change log for 5.12:

Core

  • Removed: JDK 1.4 and Javadoc annotation support
  • Added: @Listeners
  • Added: IAttributes#getAttributeNames and IAttributes#removeAttribute
  • Added: testng-results.xml now includes test duration in the <suite> tag (Cosmin Marginean)
  • Added: Injection now works for data providers
  • Added: TestNG#setObjectFactory(IObjectFactory)
  • Added: Priorities: @Test(priority = -1)
  • Added: New attribute invocation-numbers in <include>
  • Added: testng-failed.xml only contains the data provider invocations that failed
  • Added: IInvokedMethodListener2 to have access to ITestContext in listeners (Karthik Krishnan)
  • Fixed: @Before* methods run from factories were not properly interleaved
  • Fixed: The TextReporter reports skipped tests as PASSED (Ankur Agrawal)

Eclipse

  • Added: New file wizard: can now create a class with annotations, including @DataProvider
  • Added: You can now select multiple XML suites to be run in the launch dialog
  • Fixed: @Test(groups = [constant]) was taking name of the constant instead of its value.
  • Fixed: Issue 476 – NPE with Groovy Tests (Andrew Eisenberg)
  • Fixed: The custom XML file is now created in the temp directory instead of inside the project
  • Fixed: In the launch dialog, now display an error if trying to pick groups when no project is selected
  • Fixed: Was not setting the parallel attribute correctly on the temporary XML file

 

References
Published at DZone with permission of Cedric Beust, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)