我使用Cargo部署了一个包含所有类的EAR,用于JavaEE(Payara)集成测试。部署可行,但是我无法确定部署后如何运行集成测试。
这个想法是在没有任何“胶水”,模型等的情况下运行测试。
但是Cargo和failsafe拒绝运行已部署的“ BackendIntegrationTestsAllInOne.ear”中的任何内容,他们只希望运行当前的“ test”目录。
在这种情况下,直接@EJB
查找将失败,例如:@EJB TestService testService
。并且new InitialContext().lookup(...)
也不起作用(无论如何都希望摆脱它)。
如何告诉Cargo或Failsafe在已部署的BackendIntegrationTestsAllInOne.ear
中运行集成测试?
摘要pom.xml
部分,以mvn cargo:start failsafe:integration-test -DskipITs=false -P cargo
启动:
<profiles>
<profile>
<id>cargo</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.12</version>
<configuration>
<container>
<containerId>payara</containerId>
<zipUrlInstaller>
<url>
https://repo1.maven.org/maven2/fish/payara/distributions/payara/5.201/payara-5.201.zip
</url>
<downloadDir>${project.build.directory}/downloads</downloadDir>
<extractDir>${project.build.directory}/extracts</extractDir>
</zipUrlInstaller>
</container>
<deployables>
...
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>BackendIntegrationTestsAllInOne</artifactId>
<type>ear</type>
</deployable>
</deployables>
<configuration>
<configfiles>
<configfile>
<file>${cargo.container.configuration.src.dir}/domain.xml</file>
<todir>${cargo.container.configuration.to.dir}</todir>
</configfile>
</configfiles>
</configuration>
<configuration>
<properties>
<cargo.glassfish.admin.port>24848... etc.</cargo.glassfish.admin.port>
<cargo.datasource.datasource.mariaDb>...</cargo.datasource.datasource.mariaDb>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<configuration>
<properties>
<cargo.jvmargs>${cargo.container.jvmargs}</cargo.jvmargs>
</properties>
</configuration>
</configuration>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Runs integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Override any original excludes -->
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>