Stop Tests on first Failure with Maven/JUnit/Spring

半世苍凉 提交于 2019-12-06 04:08:38

This is more a remark, than an answer, but still, maybe you'll find it useful.

I'd recommend separating your integration tests into a separate phase, and running them with Failsafe, rather than Surefire. This way you can decide whether you need to run only fast unit tests, or the complete set with long-running integration tests:

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <!-- Uncomment/comment this in order to fail the build if any integration test fail -->
                <execution>
                    <id>verify</id>
                    <goals><goal>verify</goal></goals>  
                </execution>
            </executions>
        </plugin>
    </plugins>

A workaround for your problem might be singling out a test into a separate execution and run it first; this way the execution would fail and subsequent surefire/failsafe executions will not be launched. See how to configure the plugin to do it.

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