I use failsafe
插入。
所以当我输入时mvn failsafe:integration-test
它是我的集成测试的主角(这很棒)。
但我想要我的jetty server
开始于pre-integration
那么阶段。我应该怎么办?
(我不想启动mvn verify
因为它涉及整个循环运行,但是mvn failsafe:integration-test
- 看起来应该是这样的)
有两个插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId> <!-- for starting jetty for integration tests -->
<version>2.16</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<!--<jettyConfig>${project.basedir}/src/main/resources/config/jetty9.xml</jettyConfig>-->
<stopKey>STOP</stopKey>
<stopPort>9999</stopPort>
<stopWait>5</stopWait>
<scanIntervalSeconds>5</scanIntervalSeconds>
<scanTargets>
<scanTarget>${project.basedir}/src/main</scanTarget>
<scanTarget>${project.basedir}/src/test</scanTarget>
</scanTargets>
<contextXml>${project.basedir}/src/test/resources/jetty-context.xml</contextXml>
<webAppConfig>
<contextPath>/${project.artifactId}-${project.version}</contextPath>
</webAppConfig>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase> <!-- In the pre-integration-test phase the Jetty server will be started -->
<goals>
<goal>run-exploded</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase> <!-- in the "post-integration-phase" it will be stopped -->
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
这是jetty和maven-failsafe-plugin使用手册:
Maven 故障安全插件 – 使用 http://maven.apache.org/surefire/maven-failsafe-plugin/usage.html#Using_jetty_and_maven-failsafe-plugin
它提供了用于将 Jetty 集成到集成测试生命周期中的示例配置。
Jetty 期间启动pre-integration-test
阶段并在 v 期间停止post-integration-test
phase.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.16</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
但是,它还特别建议您使用verify
phase:
建议您不要直接调用
预集成测试、集成测试或后集成测试阶段
但您可以通过指定验证来运行集成测试
阶段。 [...]
这允许您设置集成测试
在预集成测试阶段的环境中,运行您的
在集成测试阶段进行集成测试,干净地拆解
集成后测试期间的集成测试环境
最终检查集成测试结果并失败之前的阶段
如有必要,进行构建。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)