You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alex Lopez <al...@flordeutopia.pt> on 2011/05/26 17:18:04 UTC

Integration testing and WAR dependencies

Hi folks,

using 3.0.3.

I'm in the process of creating a test module for my multi-module web 
project, to perform integration tests.

I have a fairly standard setup, a WAR-type module depending on several 
other modules. I have some classes I want to test residing on the WAR 
and some in other modules.

I thought I could count on transitive dependencies, ie.: add just the 
war as dependency in the test module and other modules will show up as 
result of transitive dependencies.

The thing is, not even the classes in the WAR show up in the test 
module. Are WAR-type modules never supossed to be added as dependencies? 
I read somewhere that transitive dependencies don't work for WARs, does 
it mean the only way to go is have nearly-empty WARs with all classes in 
other modules, on which the WAR depends?

(just to confirm this, I changed temporarily the packaging type of my 
WAR module to JAR, and the test module picked up all transitive 
dependencies...)

What is the recommended aproach to organize integration testing in a 
maven multi-module webapp project?

Thanks and have a good day,
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Integration testing and WAR dependencies

Posted by Alex Lopez <al...@flordeutopia.pt>.
Thanks Wayne, really useful explanations. I already had googled a bit 
about this but, as always, one cannot expect to find good examples or 
practices out there and I have a high respect for this list opinions, 
specially about "the maven way" which I see now again and again ends up 
always with less headaches in the long-term.

Em 26-05-2011 16:40, Wayne Fay escreveu:
>> The thing is, not even the classes in the WAR show up in the test module.
>> Are WAR-type modules never supossed to be added as dependencies? I read
>
> Try packaging a utility class file in a War, and then run it from
> "java -cp blah.war YourClass." War files are not understood by the
> JVM, only Jar files are valid classfile containers. For this reason,
> it is not really valid to have a War module as a dependency except in
> an Ear module (or perhaps another War module where you're using
> overlays).
>
>> somewhere that transitive dependencies don't work for WARs, does it mean the
>> only way to go is have nearly-empty WARs with all classes in other modules,
>> on which the WAR depends?
>
> This is the "correct" way to set things up. Put your class files in
> one or more Jar modules and then depend on those modules in your War
> project. Localize unit and integration testing within the Jar module
> if possible.
>
>> What is the recommended aproach to organize integration testing in a maven
>> multi-module webapp project?
>
> You can still do integration testing with your War file. But this
> should mean deploying the War file to a container and running some
> integration testing via Cactus, Selenium or perhaps failsafe.
>
> Here's some more info:
> http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing
> http://andrewmccall.com/2008/09/integration-testing-in-maven-with-maven-cargo-httpunit-and-selenium
> and you'll find more links on Google with the terms "maven war
> integration testing."
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Integration testing and WAR dependencies

Posted by Wayne Fay <wa...@gmail.com>.
> The thing is, not even the classes in the WAR show up in the test module.
> Are WAR-type modules never supossed to be added as dependencies? I read

Try packaging a utility class file in a War, and then run it from
"java -cp blah.war YourClass." War files are not understood by the
JVM, only Jar files are valid classfile containers. For this reason,
it is not really valid to have a War module as a dependency except in
an Ear module (or perhaps another War module where you're using
overlays).

> somewhere that transitive dependencies don't work for WARs, does it mean the
> only way to go is have nearly-empty WARs with all classes in other modules,
> on which the WAR depends?

This is the "correct" way to set things up. Put your class files in
one or more Jar modules and then depend on those modules in your War
project. Localize unit and integration testing within the Jar module
if possible.

> What is the recommended aproach to organize integration testing in a maven
> multi-module webapp project?

You can still do integration testing with your War file. But this
should mean deploying the War file to a container and running some
integration testing via Cactus, Selenium or perhaps failsafe.

Here's some more info:
http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing
http://andrewmccall.com/2008/09/integration-testing-in-maven-with-maven-cargo-httpunit-and-selenium
and you'll find more links on Google with the terms "maven war
integration testing."

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org