If you are using JBoss AS5.x or AS6.x you can use the JSFUnit Deployer. That allows you to "JSFUnify" the EAR at deploy time without any changes to your WAR. You don't even have to bundle the tests but instead put them in a seperate directory. See JSFUnitWithASMicrocontainer.
If you are using another container then my suggestion is to have a JSFUnit WAR module that depends on the regular WAR (I think you are already doing that). Then use a profile in your EAR module to include the JSFUnit WAR only when you are testing.
Hope that helps,
Thank you for your answer!
I already saw the JSFUnit Deployer for JBoss 5 and got angry about my JBoss 4.2.2. Maybe we'll make an upgrade soon (I hope so)
Nevertheless, your hint with the separate profile for my EAR profile is probably a suitable solution. Up to now, I've tried something "completely different": I created 3 maven modules, depending on each other. First, there is one module which implements the tests and creates the JSFUnified WAR (as you suggest in the HowTo). Another module is somehow a copy of my original EAR module which assembles the application to an EAR but using the JSFUnified WAR instead of the original one. And the third module is responsible for deploying the new EAR and executing the tests. This works pretty good (there are only some small issues with the cargo plugin - but this is just cosmetical).
Maybe I will try the way of defining another profile (it sounds a bit better to me than my solution). And I'm looking forward to upgrade the JBoss.
Then use a profile in your EAR module to include the JSFUnit WAR only when you are testing.
Hope that helps,
I just wanted to inform you that I tried this and maybe my insights are useful for someone else:
I now tried to define another profile and use it in the EAR module to produce the modified EAR. Although it was basically working, it turned out that this is not a perfect solution:
Since the produced EAR is different from the standard one, a classifier has to be added to the "module path" of the EAR in order to mark that there is something different. Thus the JSFUnit-tests are using the EAR with the classifier and the "normal" integration tests are using the standard EAR without the classifier. But since it is not possible to produce both EARs within one maven run, some problems arise when someone wants to build the application and run both the integration tests and the JSFUnit tests (either the JSFUnified EAR or the standard EAR is out of date).
Another problem comes up when using Continuum. I tried to come up with a solution by defining custom builds in continuum, but none of the tried ways worked perfectly and everything sounds like an ugly hack (from the maven point of view).
So I decided to go back to my 3-module-solution which still works fine.