[jboss-user] [EJB 3.0] - Re: EjB3 & JBoos AS - JUnit testing

obfuscator do-not-reply at jboss.com
Fri May 4 07:55:16 EDT 2007

"karl.martens" wrote :   I've just had a brief look at the Jakarta Cactus and it look promising.  I will investigate and see if I can get it to work for my needs.
  |   AS far as connecting as a client it depends what you mean.  I had considered using a test running like Watir and Ruby to test the application via http request response.  I will use this approach for high level business case tests but I've found that the speed of these type of tests make it difficult to get high degrees of test coverage.
  |   If you meant connecting directly to the EJBs vie a remote interface, I hadn't considered that.
  |   Thanks for your reply much appreciated, gave me something to consider.

No problem. Unit testing of EJB:s is still a pain I think. I've really been waiting for the embeddable container, since this would simplify a great deal. I usually write separate ejbs for unit testing, just to be able to inject any dependencies I need. Regarding the client high level-approach, I agree with you that it's pretty useless since the pre and postconditions are to much of a hassle to check. Would be sweet to have a TestNG-pojo and just get the entity manager in a nice and clean way. Of course, this requires being in the same JVM, and hence you need to deploy the tests to the server (cactus helps here), or start the server in local JVM (embeddable). 

The other problem I'm having is that maven expects the tests to be able to run directly after compilation, which usually makes me having a separate subproject for my ejb unit test. This does encourage refactoring a lot of logic into utility classes (makes that logic easily testable) , which I think is good, but the tests needs to be separated from the actual build and deploy process, which I think is really bad.

I like this discussion. Does anyone have a nice clean solution for how to unit test J2EE projects?

I'm happy to contribute with the stuff I've came up with (config, patterns, code etc).


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043149#4043149

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043149

More information about the jboss-user mailing list