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.
(...) automation module is the WebDriver based automation tests for testing UI. It depends on web war but there is no package dependency. I am deploying to tomcat using cargo maven plugin. I want to build web wars from source, on the fly just before running the automation tests, then deploy on tomcat and then run tests. I can do all these using ant build but unable to using maven
This is definitely doable (and I've done it numerous time). But I'm not sure to understand your current project structure (especially, where the tests are located).
Here is the structure I suggest:
. ├── functests │ ├── pom.xml // here we configure maven to run cargo & it tests │ └── src │ └── it │ ├── java │ │ └── ... // functional tests will go here │ └── resources ├── pom.xml // aggregating pom └── mywebapp // the application under test ├── pom.xml └── src ├── main │ ├── java │ ├── resources │ └── webapp └── test ├── java └── resources
And for the details of the pom setup, have a look at Functional testing with Maven, Cargo and Selenium , it contains all the details required.
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 .
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.
"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:
/myWebApp/myWebApp-web/pom.xml
) This should do what you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.