Unfortunately the following does not seem to work in TestNG 5.4: ... <classes> <class name="myPackage.Example"/> </classes> ...

Perhaps that's a bug.

The awesome thing about this is that your Example class does NOT need to have a public non-arg constructor. This allows you to do this kind of white box testing with very little boiler plate code. The one possible downside is that your testing logic is hard to exclude from your release builds because it's part of the class. Personally, I can accept that because I place higher value on grouping related information - the class and it's unit test. Besides, a person could probably filter out unit test code at compile time with Ant's Filter task.