【发布时间】:2012-08-09 12:29:35
【问题描述】:
我使用的是 maven 2,集成测试在 *IT.java 文件中。当我运行命令 mvn failsafe:integration-test 集成测试运行良好。但是当我运行mvn integration-test 时,它不会运行我的集成测试。如何删除前缀 failsafe: ?
在 pom.xml 我使用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
更新
我还尝试关注pom.xml 设置,然后关注mvn clean verify。我只得到了 JUnit 测试的可靠报告。控制台输出仍然缺少 JUnit 集成测试。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>failsafe-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>failsafe-verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
现在我通过插件设置禁用单元测试:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Disable unit tests -->
<skip>true</skip>
</configuration>
</plugin>
我运行mvn clean verify 我的故障安全集成测试运行!但是为什么它不能与 surefire 单元测试一起使用呢?有什么想法吗?
【问题讨论】:
-
你在哪里定义的?在构建区域还是在插件管理区域?
-
您是否明确指定了阶段?我通过similar issue 帮助了其他人并添加了阶段帮助。根据文档,目标应该默认绑定到
integration-test阶段,但在明确添加阶段之前它不起作用。 -
要运行集成测试,您必须调用生命周期阶段:验证。如果您调用 lifecylce 集成测试,则缺少集成测试后阶段 (maven.apache.org/guides/introduction/…)。啊,你用的是 JUnit 还是 TestNG?
标签: maven continuous-integration integration-testing maven-failsafe-plugin phase