Corrections from Christian Bauer and Cedric Beust on my comments on TestNG

I have to get my comments feature working on my blog app (BBWeblog). Christian Bauer and Cedric Beust both emailed me with corrections to my blog entry about Christian’s comments on using TestNG for testing beans developed using JBoss’ EJB3.0 implementation.

Cedric said:

I just read your post about TestNG and EJB3 and I have a few thoughts.

Indeed, TestNG is not just about unit testing. The idea behind TestNG is the realization that mocks and unit tests (testing one class in isolation of all others) only get you so far. At some point, you really need to test what is actually going into production, and if it means making real database modifications and displaying real HTML pages, so be it.

The main feature that got Christian excited, though, is not exclusively an integration feature: test groups. Once you get used to them, you just can’t live without them.

Another popular feature of TestNG is parameters: you can pass parameters to your test methods (which simplifies your testing code quite a lot, as you’ll find out) and the more sophisticated version of parameters: Data Providers (@DataProvider). Look them up in the documentation and let me know what you think!”

I need to spend some time and check out TestNG (maybe in future I should try things out for myself before I make comments… :0 )

Christian Bauer also emailed me and wanted to make a couple of clarifications to the points I made:

He is currently 95% complete with the mapping chapters, but still has a way to go on the last third of the book, so it doesn’t sound like we’ll be seeing it soon.

– 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.”

I think I missed the main point that Christian was making in his article. TestNG, as well as being a unit testing framework, can also be used to integration test EJB3.0 beans when running in container. I lost sight of the point that EJB3.0 bean are still POJOs, and can still be tested outside the container using a framework like TestNG or JUnit. This is a huge benefit and a huge change from 2.x days. Thanks for the comments guys.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.