-
1. Re: EjB3 & JBoos AS - JUnit testing
karan42in May 4, 2007 3:59 AM (in response to karl.martens)Hi karl...
sorry for this reply this mite not be appropriate to ask u but.. could u help me develope an EJB3.0 application in eclipse 3.2 or jboss ide 1.6..
which one would better.. kindly help me out. -
2. Re: EjB3 & JBoos AS - JUnit testing
obfuscator May 4, 2007 4:47 AM (in response to karl.martens)You can use Jakarta Cactus. This is essentially a two-component solution that has a local test runner that interfaces to a test runner servlet on the server via IP. I guess you already considered the other alternative: to connect as a client and setup preconditions via a direct connection to the db or similar.
-
3. Re: EjB3 & JBoos AS - JUnit testing
karl.martens May 4, 2007 5:40 AM (in response to karl.martens)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. -
4. Re: EjB3 & JBoos AS - JUnit testing
karl.martens May 4, 2007 6:18 AM (in response to karl.martens)Karan42in - I've moved your question with reply to its own thread http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043113#4043113
If you or anyone else has something to say on your topic I would ask that all responses be directed to the new thread.
Thanks. -
5. Re: EjB3 & JBoos AS - JUnit testing
obfuscator May 4, 2007 7:55 AM (in response to karl.martens)"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).
Regards