The TestNG IDEA plug-in has an interesting feature that I just implemented in
the Eclipse plug-in:  if you press Ctrl-1 (Quick Fix) on a JUnit test
class, the plug-in will give you the option to convert it to TestNG, either with
JDK5 annotations:

or JavaDoc annotations:

The operations performed by this extension are very simple:

  • Remove all the JUnit imports
  • Add TestNG imports (for JDK5 annotations only)
  • Import AssertJUnit
  • Remove extends TestCase
  • Add @Test annotations on top of any method that starts with
    "test"
  • Add @Configuration(beforeTestMethod = true) on top of setUp()
  • Add @Configuration(afterestMethod = true) on top of
    tearDown()
  • Add @Factory on top of suite()

And that’s it!  These are fairly simple changes and again, I am struck
at how intuitive the Eclipse API is.  Manipulating the AST is a real
pleasure and as you can see above, the ASTRewriter gives you a lot of
goodies for free, among which unlimited undo and a nice preview window.