I have the following default configuration for the Maven Failsafe Plugin:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<executions>
<execution>
<id>default-integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>default-verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
The documentation states that the default classpath includes both the target/test-classes
and target/classes
directories, in that order. However, when I run mvn clean install
or mvn integration-test
, I don't see the classes
folder as part of the classpath. This is causing test failures as I am injecting a class from my source into the test and I get a NoClassDefFound
exception.
Here is the verbose output:
[DEBUG] test(compact) classpath: test-classes package.jar javax.inject-1.jar cdi-api-1.2.jar ...
As you can see the classes
folder should have been added before the project dependencies, but it is not.
However, when I run the mvn failsafe:integration-test
goal specifically, instead of a phase, then the classpath includes classes
immediately after test-classes
and the tests are successful, which is consistent with the documentation.
What am I not understanding about the build process? Why is the classpath different when running the phase as opposed to running the goal? How can I get classes
in the classpath even when running the phase?