I have the following failsafe setup and it works as expected when I run things "normally" (= with mvn verify, and don't use dependenciesToScan):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<failIfNoTests>true</failIfNoTests>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/mySuite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
- The integration tests run as expected,
- The verify explodes as expected if no tests are specified, and
- The build breaks in the verify phase when there are integration test failures
However, when I take exactly the same failsafe setup, and extend it with "dependenciesToScan" in a "test-runner" pom / project that just runs the tests from the jar file (so I don't recompile / rebuild the whole project every time I want to run the integration-tests):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<failIfNoTests>true</failIfNoTests>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/mySuite.xml</suiteXmlFile>
</suiteXmlFiles>
<dependenciesToScan>
<dependency>${test.library.groupId}:${test.library.artifactId}</dependency>
</dependenciesToScan>
</configuration>
</plugin>
Here's what happens:
- The integration-tests run as expected,
- The build fails cause it doesn't find any tests to run (in the verify phase!? - see below), and
- When I remove the failIfNoTests, the build is reported to be successful even though there are test failures
I checked all kinds of stuff, and tried a few things, so I'm not sure what I might be missing here. The plugin configuration obviously works without any trouble if I don't use dependenciesToScan.
Is there any chance there's a bug in the failsafe plugin that breaks the verify business logic when you're using dependenciesToScan?
Tests run: 79, Failures: 6, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) @ test-runner ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-failsafe-plugin:2.18.1, parent: sun.misc.Launcher$AppClassLoader@42a57993]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify' with basic configurator -->
[DEBUG] (s) basedir = /xyz/test-runner
[DEBUG] (f) encoding = UTF-8
[DEBUG] (s) failIfNoTests = true
[DEBUG] (s) reportsDirectory = /xyz/test-runner/target/failsafe-reports
[DEBUG] (s) skip = false
[DEBUG] (f) summaryFile = /xyz/test-runner/target/failsafe-reports/failsafe-summary.xml
[DEBUG] (s) testClassesDirectory = /xyz/test-runner/target/test-classes
[DEBUG] (s) testFailureIgnore = false
[DEBUG] -- end configuration --
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:27 min
[INFO] Finished at: 2015-03-13T22:44:46-04:00
[INFO] Final Memory: 13M/250M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project test-runner: No tests to run! -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project test-runner: No tests to run!