Maven + Surefire return code is 0 on failed tests

百般思念 提交于 2019-12-04 09:44:17

I managed to have it working with two different configurations, using groups and using folders using just surefire

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.13</version>
    <configuration><excludedGroups>com.testlib.IntegrationTest</excludedGroups>
    </configuration>
    <executions>
        <execution>
            <id>integration-test</id>
            <phase>integration-test</phase>
            <goals>
                goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
                      <excludedGroups>com.biicode.testlib.UnitTest</excludedGroups>
                      <groups>com.testlib.IntegrationTest</groups>
            </configuration>
        </execution>
    </executions>

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <excludes>
            <exclude>**/integration/*.java</exclude>
        </excludes>
    </configuration>
    <executions>
    <execution>
        <id>integration-test</id>
        <phase>integration-test</phase>
        <goals>
            <goal>test</goal>
        </goals>
        <configuration>
        <skip>false</skip>
        <excludes>
            <exclude>none</exclude>
        </excludes>
        <includes>
            <include>**/integration/*.java</include>
        </includes>
    </configuration>
  </execution>
  </executions>
</plugin>

First check if there is same parent pom which configures:

<testFailureIgnore>true</testFailureIgnore>

somewhere...you can check this via:

mvn help:effective-pom

Furthermore you are trying to run integration test with maven-surefire-plugin which is simply wrong. For integration tests use the maven-failsafe-plugin. One other thing is to name your integration tests in the right way like IT*.java, *IT.java etc.

One other thing is why are you using such an old Maven version check Maven 3.0.4.

Ah sorry. Oversight that you are talking about integration tests. If you correctly using the maven-failsafe-plugin for integration tests it contains a particular goal verify which is intended to check the result of the integration tests afterwards. But you need to separately configure that via an execution block and binding to a particular lifecycle phase.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!