Christian Bauer, one of the developers of Hibernate and co-author (with Gavin King) of the excellent Hibernate book, Hibernate in Action, writes in the Hibernate blog on using TestNG.
I don’t have any experience with TestNG, but have used JUnit extensively. From the comments in his blog, Christian seems very excited about using TestNG to test EJB3.0 beans, but the thing that I am not sure about (and I may be wrong about this), is that it looks like it depends on the EJB3.0 container to be booted in order to run the tests. Isn’t this moving away from the core principals of unit testing? It seems like TestNG is more like a Cactus-like framework that tests things inside the container?
Also, what happened to the promises of testing EJB3.0 components outside of the container, as now they are more like POJOs with simple annotations?
On another note, Christian mentions that the updates to the Hibernate in Action for the second edition are 95% complete, so hopefully we’ll be seeing that on shelves soon.
12/23/05 – Christian emailed me to clafify a couple of points: the mapping sections of the book are 95% complete, but there is still the last 3rd of the book to complete, so it doesn’t sound like it will be ready for a while yet.
Additional comments from Christian:
– You need the EJB3 container (which starts in 2 seconds on my machine) to do integration testing. You don’t need it for unit testing.
– You can test EJB3 beans without a runtime container. Just instantiate them and call a method, they are POJOs.
– TestNG can do whatever you like, it is not bound or tied to anything. It just happens that it makes integration testing very easy, something JUnit makes very difficult.”
So TestNG can be used to integration test EJB3.0 beans when running in the container, but the key point is that EJB3.0 beans are just POJOs and can get tested outside of the container. Thanks for the clarifications.