We are going forward with Seam as the foundation of our application architecture for "the big project". So, I need some definitive answers on unit testing with Seam.
There is conflicting information regarding how one should go about unit testing components. One camp says to use SeamTest, the other camp says that you should not use it.
See in particular: here and here.
Or search for "unit test could not find datasource" with "include all items" set to true in the Seam forum.
Q1. What is the right way to unit test Seam components?
Q2. How does one test without SeamTest?
The same problem that everyone seems to run into is that when they make the call:
The testing errors out since the datasource can not be found. The suggestion was made to register the datasource in JNDI, but no one (including myself hence this post) talks about how to do so without relying on SeamTest to do so.
What are all the steps that one needs to take to perform unit testing against a datasource without using the embedded container?
Q2. How does one test with SeamTest?
Everyone seems to be getting the "cannot find datasource" error because the test gets run before the embedded container is actually initialized. The generally agreed upon workaround seem to be to initialize the datasource before every test is run:
This is how we did it on our first Seam project. The code is ugly and hacking; bless the programmer that took care of it for the team.
Is this really the "right" way to do it. I feel like I am doing something wrong and this is a workaround. What is the official way to deal with this? Is this normal behavior or are all of users doing something wrong?
What is the official way to deal with the issue? Is it really as simple as "configure everything exactly the same way as the sample projects"? Remember everyone is encountering this error using seam-gen'd projects.
This is really confusing. Gavin, Pete, we need your magic on this, you are the ones who can shed the light onto our ignorance. This may sound like craziness to you, but it is really frustrating.
Looking forward to your reply! :)