Maven故障安全插件不会影响构建

时间:2015-11-18 09:35:22

标签: maven maven-failsafe-plugin

即使集成测试失败,Maven构建过程也会成功完成。为什么会这样?我使用Maven故障安全插件 这是日志的输出:

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.235 sec <<< FA
ILURE! - in Case1IT
testCase(Case1IT)  Time elapsed: 4.235 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<Hello java world![!]> but was:<Hello java
world![]>
    at Case1IT.testCase(Case1IT.java:36)
Results :

Failed tests:
Case1IT.testCase:36 expected:<Hello java world![!]> but was:<Hello java world!
[]>

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

[INFO]
[INFO] --- jetty-maven-plugin:9.2.2.v20140723:stop (stop-jetty) @ webcont ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Multi Chapter Simple Parent Project ................ SUCCESS [  0.000 s]
[INFO] hellojavaworld ..................................... SUCCESS [  7.422 s]
[INFO] webcont ............................................ SUCCESS [ 13.313 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

一般来说都是假的。

有pom.xml源:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19</version>
            <executions>
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
            </executions>
</plugin>
<plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.2.v20140723</version>
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <stopPort>9966</stopPort>
                <stopKey>abc</stopKey>
                <webApp>
                    <contextPath>/hellojavaworld</contextPath>           
                </webApp>    
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run-war</goal>
                    </goals>
                    <configuration>
                        <daemon>true</daemon>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

1 个答案:

答案 0 :(得分:0)

基于documentation,您应该像这样使用它:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.19</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>