Editing to add additional information at the bottom
I've looked here: What is a good way in maven/surefire to clean up after unit tests, whether they pass or not? but it's not helping me. I'm probably configuring failsafe and/or surefire incorrectly.
I have jUnit tests that depend on configuration files being in place, and I've added copy-rename-maven-plugin in the process-test-resources phase to set up test copies of the config files for the jUnit tests, and copy-rename-maven-plugin and maven-clean-plugin in the post-integration-test phase to restore everything back the way it was when I'm done. But when the jUnit tests fail, the subsequent phases aren't running, even though I have failsafe plugin as well.
The jUnit examples in the failsafe documentation all use surefire, so I'm confused about how to get failsafe to run them - or if that's even what I need to do.
I've got jUnit declared as a dependency
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
I've got failsafe plugin in the build:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<!--
<configuration>
<skipITs>true</skipITs>
</configuration>
-->
<executions>
<execution>
<id>run-nonautowired-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
I don't have any integration tests following the *IT naming conventions, only the jUnit tests following the *Test naming conventions. I'm just trying to use failsafe as a way to ensure my cleanup gets done. I've tried skipITs true and I've tried commenting that out. I've tried with and without the configuration includes.
I've currently got surefire plugin commented out, but it's still running the tests and failing the build, based on the output I'm seeing:
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
-->
What am I missing/doing wrong? It seems I had this working before, but it was running the jUnit tests twice in a different project that used Spring, where I needed to add tests that didn't use Spring - but I can't remember what I did differently.
I'm doing this inside IntelliJ 14.1.5, but running the Maven Lifecycle to the verify phase rather than having IntelliJ run the jUnit tests directly.
Also, it seems that its surefire 2.12.4 that is running the default-test, and I have no idea where that is coming from.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project RefRange: There are test failures.
Where should I look to see where 2.12.4 is coming from? And how can I get this to run the jUnit tests once, and continue on to the next phase even if they fail?
Thanks for any help,
Rebeccah
Additional information: After uncommenting my surefire plugin, adding
<skip>false</skip>
<skipTests>true</skipTests>
to its configuration, changing the failsafe includes to
<includes>**/*Test.java</includes>,
and running mvn verify -X, I get the following immediately after my intentional test failure:
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] ref_range_by_RTest.testGetConfigManager:56
Expected: is "C:\Program Files (x86)\Apache Software Foundation\Apache Tomcat 8.0.27/app_rsrcs/refrange/data"
but: was "C:\Program Files (x86)\Apache Software Foundation\Apache Tomcat 8.0.27/app_rsrcs/refrange/data-not"
[INFO]
[ERROR] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting. outputEncoding}.
[INFO]
[INFO] --- maven-failsafe-plugin:2.20:verify (run-nonautowired-tests) @ RefRange ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-failsafe-plugin:2.20:verify from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-failsafe-plugin:2.20, parent: sun.misc.Launcher$AppClassLoader@647e05]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-failsafe-plugin:2.20:verify' with basic configurator -->
[DEBUG] (s) basedir = C:\Git\clincor-clindev\refrange
[DEBUG] (s) reportsDirectory = C:\Git\clincor-clindev\refrange\target\failsafe-reports
[DEBUG] (s) skip = false
[DEBUG] (f) summaryFile = C:\Git\clincor-clindev\refrange\target\failsafe-reports\failsafe-summary.xml
[DEBUG] (s) testClassesDirectory = C:\Git\clincor-clindev\refrange\target\test-classes
[DEBUG] (s) testFailureIgnore = false
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@2eef62
[DEBUG] -- end configuration --
[DEBUG] Failsafe report directory: C:\Git\clincor-clindev\refrange\target\failsafe-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.976 s
[INFO] Finished at: 2017-05-17T20:54:09-07:00
[INFO] Final Memory: 17M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20:verify (run-nonautowired-tests) on project RefRange: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Git\clincor-clindev\refrange\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20:verify (run-nonautowired-tests) on project RefRange: There are test failures.