I'm looking for a way to apply TDD to Session Beans.
can anyone provide advices and links on how to unit test them ?
how to use JUnit to do so ?
P.S : I'm new to Test Driven Development and Session Beans.
I'm using EJB v2.
I'm assuming you are talking about EJB2.x Session Beans. For these kind of animals, what I like to do is:
You don't say which version of EJB you're using. If it's EJB v3, check out Ejb3Unit. From the website:
Ejb3Unit is a JUnit extention and can execute automated standalone junit tests for all EJB 3.0 conform Java EE projects. The out of container test approach leads to short build-test-cycles, because no container deployment is necessary anymore.
However I would advocate separating out functionality from the EJB-specifics. This will allow you to test complex functionality outside the container and without using frameworks such as the above. The majority of your tests would be testing POJOs (plain old Java objects) and relatively few would focus on your persistence framework testing.
EDIT: So if you're using EJB v2 then obviously ignore the first point. The second point remains valid, however.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With