I was happy to discover that TestNG is now covered in a full chapter of the book Beginning POJOs by Brian Sam-Bodden.
The author puts aside JUnit, and introduces the reader to TestNG concepts. After a concise intro, the author builds more complex tests integrating DbUnit and EasyMock (as you may already know EasyMock 2 is already JUnit-free; in previous posts I have started posting ideas about a JUnit-free JMock).
Regarding the examples provided in the book, I have a single remark: having in mind that building a Hibernate SessionFactory
is considered an expensive operation, I would use other mechanisms from TestNG that may help running the tests more quickly (by guaranteeing that the SessionFactory
is created/initialized only once): @BeforeGroup
(guaranteed to run once before a named group of tests), @BeforeTest
(which is guaranteed to run once before the tests) or @BeforeSuite
(running once before the whole suite).