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 89 posts at DZone. You can read more from them at their website. View Full User Profile

Testing to the Speed of Light

01.20.2011
| 6620 views |
  • submit to reddit

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!

 

From http://beust.com/weblog/2011/01/19/testing-to-the-speed-of-light/

Published at DZone with permission of Cedric Beust, author and DZone MVB.

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

Tags: