When you are under pressure to ship a feature, every little detail that makes your coding process faster counts. Especially when it’s about writing tests. For example, if you are one of the many people who don’t use TDD, you first write a class, iterate a few times over the initial implementation and when you’ve reached a point where you are satisfied, you are ready to write a test for it.

With TestNG and Eclipse, writing tests just became easier.

The “New TestNG class” wizard has just received a new page that looks at the Java file that’s currently in your editor and then allows you to select public methods in it. Methods selected in this page will be automatically included in the generated test class, with a default implementation that throws an exception, so you don’t forget to implement it:

The wizard is also pretty clever in trying to stay as much out of the way as possible. For example, it will automatically detect the package, come up with a test class name and, more importantly, it will guess what is the most appropriate directory for your test class. For example, if you are using Maven, this directory will be src/test/java:

Happy testing!