Previous: Maven implementation of Web application integration Test Self-initiative-Test Self-initiative (WebTest Maven Plugin)
Before describing how to use the WebTest plug-in to implement the Web integration test in Maven, here's a legacy issue, which is that when you run Maven's intergation test, the Web application is already deployed in the container in the in service state. So is the deployment of Web applications enough to be proactive? In our company's system, because uses the WebLogic cluster, has written the footstep to realize the deployment, has spent a lot of manpower and resources, actually the Java Web application already had the gospel, It is a plug-in artifact that proactively installs containers and deploys applications: Cargo-maven2-plugin, which is compatible with all current mainstream servers such as JBoss, Tomcat, GlassFish, Jetty, and more.
It is very easy to configure, add Cargo-maven2-plugin in Build, in order to realize the integration test self-initiated, declare the integration test phase before calling Cargo:start launch container and deploy the application, integrated test end call Cargo: Stop to close the container. The default start container ends at the end of the Maven lifetime, and sometimes, for debugging, it is possible to invoke Cargo:run to launch the container and deploy the application, and then end the container execution with CTRL + C when needed.
In order to implement the container start-up and deployment of their own initiative, but also to provide some configuration parameters to the plug-in, the following is a demonstration sample, cargo also has a lot of other functions, detailed can refer to: Cargo own initiative to deploy the official site
<plugin> <groupid>org.codehaus.cargo</gr Oupid> <artifactId>cargo-maven2-plugin</artifactId> <versio N>${project.cargopluginversion}</version> <configuration> <!--definition Container--<container> <!--Co Ntainer Type Jetty/tomcat/weblogic/jboss etc--and <containerid>${project.cargo.contain er}</containerid> <!--Specify the container download path, save the path, unzip the path, put in the target folder can be clean when you voluntarily clear-- <zipUrlInstaller> <url>${project.cargo.contain Er.url}</url> <downloaddir>${project.build.directory}/${project.cargo.cont Ainer}/downloads</dowNloaddir> <extractdir>${project.build.directory}/${project.cargo.container}/e Xtracts</extractdir> </zipUrlInstaller> <!- -Cargo Log Storage-<log>${project.build.directory}/logs/cargo.log</log> <!--container Log storage--<output>${project .build.directory}/logs/container.out</output> </container> <!--join container related configuration information-<configuration> < !--set Deploy home--
Maven implements Web application integration test yourself proactively-deploy your own initiative (WebTest Maven Plugin)