When I build a project with Maven, dependencies with scope test
seems to be out of scope during the integration-test
phase. Is this by design, or is there anything I can do to have dependencies with scope test
to be included during the integration-test
phase?
One answer here on SO suggests that test dependencies are in scope during the integration-test phase, but the answer is just a statement with no references. However, this does not appear to be how Maven works for me.
When I change a given dependency's scope from test
to compile
, the given dependency is (as expected) available during the integration-tes
t phase.
Should the test
scope apply to the integration-test
phase, or will I have to set dependency scope to compile
in order for them to be available during the integration-test
phase?
This is the relevant part of the POM
file. What I'm doing is that I attempt to start an instance of a MockServer during the integration test phase. However, it fails as the com.company.msd
dependency not is included.
<dependencies>
<dependency>
<groupId>com.company.msd</groupId>
<artifactId>MockServerDemo</artifactId>
<version>0.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>
[...]
<plugin>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-maven-plugin</artifactId>
<version>3.9.17</version>
<configuration>
<serverPort>1080</serverPort>
<proxyPort>1081</proxyPort>
<logLevel>DEBUG</logLevel
<initializationClass>com.company.msd.server.DefaultExpectationInitializer</initializationClass>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Note! If I add the dependency as a plugin dependency, it works. However, I'm still curious if Maven by design not includes test scoped dependencies in the integration-test
phase.