我似乎无法弄清楚如何让我的maven项目部署然后进行测试,如果它没有在我想运行的测试的glassfish服务器上运行,它显然会失败,有人可以给我一些文档或一个关于如何做到最好的例子。
感谢。
答案 0 :(得分:1)
我之前通过在多模块maven项目中创建单独的模块进行测试来完成此操作。在预集成测试执行阶段使用Cargo maven插件部署到您的appserver,然后使用maven-failsafe-plugin将集成测试目标绑定到集成测试阶段。将测试类放入src / test / java中,并在IT前面加上所有测试类名称的前缀。这是我的pom.xml中的一个片段:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.glassfish.deployment</groupId>
<artifactId>deployment-client</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<configuration>
<container>
<type>remote</type>
<containerId>glassfish3x</containerId>
</container>
<deployables>
<deployable>
<groupId>com.foo.example</groupId>
<artifactId>example-app</artifactId>
<type>ear</type>
</deployable>
</deployables>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>${glassfish.host}</cargo.hostname>
<cargo.glassfish.adminPort>${glassfish.adminport}</cargo.glassfish.adminPort>
<cargo.remote.username>${glassfish.username}</cargo.remote.username>
<cargo.remote.password>${glassfish.password}</cargo.remote.password>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>deploy-cargo</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deployer-redeploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<configuration>
<skip>false</skip>
</configuration>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>