views:

70

answers:

3

I have recently started migrating my project from ant to maven. I have two module in my application which I am able to build using maven.

Now I have automated tests project which use Web Driver for testing UI functionality. What I am trying to do using maven is to build both module wars and deploy them on to tomcat. Then run automation tests against them and pass the build if automation test passes. I have configured my pom like this(just mentioning important part):

<packaging>pom</packaging>
<modules>
        <module>../module1</module>
        <module>../module2</module>
</modules>

Now Both the projects get build and deploy but It doesn't run automation tests. The reason I thought is that packaging type is POM. But If I change it to war it starts throwing error.

I can think of creating third pom for automation and parent pom to include that as module also. But I am thinking whether this is a right way. It should be a very common scenario and maven should be supporting it directly.

A: 

"I can think of creating third pom"
Do you have only two POMs? Each project/module needs its own POM.

Look here for more information on integration tests with maven: http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing

Edit: I don't understand exactly what your project layout looks like. But I guess it should look somehow like this:

File structure

myWebApp/
    pom.xml
    myWebApp-web/
        pom.xml
    myWebApp-integration-tests/
        pom.xml

/myWebApp/pom.xml

<packaging>pom</packaging>
<modules>
    <!-- packaging: war; here are the sources and unit tests -->
    <module>myWebApp-web</module>

    <!-- packaging: java; here are the integration tests -->
    <module>myWebApp-integration-tests</module>
</modules>

With this setup, /myWebApp/mvn deploy will execute the following steps:

  1. Build the root project (does nothing, as there are no sources)
  2. Build myWebApp-web
  3. Deploy myWebApp-web (has to be configured in /myWebApp/myWebApp-web/pom.xml)
  4. Execute tests in myWebApp-integration-tests

This should do what you want.

Arian
Thanks for reply Arian. I have three pom's already. What I am trying to achieve is that this third project build should build the first two and then only trigger tests.
Ankit
I extended my answer accordingly.
Arian
Thanks a lot Arian... but it doesn't help. I have tried to make my question more meaningful. See if I am able to explain it clearly now. I don't think solution you provided will help in my case.
Ankit
+1  A: 

I don't think that 2 war modules with a shared integration test module is a very common scenario.

However, you could get this working with Hudson.

  • Set up a job in Hudson to deploy your parent level pom, which will result in the war modules being deployed as you currently have.
  • On success of the previous job, trigger another job to run the integration-tests.

You may want to use profiles to activate integration testing, or more specifically to prevent integration tests from being executed during the first job.

I have earlier this year set-up a basic Hudson server in roughly an hour.
Hudson has direct support for maven builds and also provides a location for your projects maven site, including all of the quality reports etc.
You can also configure Hudson to "watch" your SCM, and initiate a build when it identifies a commit.

crowne
Thanks crowne.I was also thinking to follow the similar approach.I am using cruise control for continuous integration. I wanted to get an idea about whether building web wars and deploying them from build file of automation tests(which we are doing currently using ant) is a good idea or not and if it is then how to do it using maven.
Ankit
+2  A: 
Pascal Thivent
Thanks Pascal... Exactly what I was looking for and a very nice article too...
Ankit