Issue
I'm using the Maven Integration Testing Framework plugin to test one goal of a custom-developed plugin. As far as the tests go, everything works well. However, there is one unexpected and undesired technicality that I have noticed:
The local repositories created for individual test cases in target/maven-it/.../test-case/.m2/repository
are always populated remotely - from the Maven Central Repository. If I run mvn clean integration-test
without being connected to the Internet, the dependency resolution results in an error after a failed connection attempt. I would expect it, however, to look for the dependencies in the "standard" cache located in USER/.m2/repository
first, where the dependencies were already present in my experiment.
It's interesting that even after adding the --offline
option to mvn clean integration-test
, online dependency resolution is still attempted.
My main question is - should this be happening? Is this the expected behavior when using the Maven Integration Testing Framework? Or do you think there might be something wrong with the way I'm using it?
Related dependencies from the pom.xml
of the tested custom-developed plugin:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.16.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-jupiter-extension</artifactId>
<version>0.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-assertj</artifactId>
<version>0.11.0</version>
<scope>test</scope>
</dependency>
Related plugins:
<plugin>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-maven-plugin</artifactId>
<version>0.11.0</version>
<executions>
<execution>
<id>installing</id>
<phase>pre-integration-test</phase>
<goals>
<goal>install</goal>
<goal>resources-its</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<systemProperties>
<maven.version>${maven.version}</maven.version>
<maven.home>${maven.home}</maven.home>
</systemProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Solution
If the dependencies would be consumed from the users local cache $HOME/.m2/repository
it could happen that parts which are already in the local cache influence the integration test. That's one of the the reasons each integration tests is completely separated from each other.
Furthermore it makes it possible to parallelise the integration tests in an easier way.
Furthermore you can configure your own settings.xml
to consume any dependencies from an repository instead directly from central this would also mean that the integration test would consume their dependencies from that
repo.
Apart from that the usage of the users local cache would make it impossible (or at least much more complicated) to create a local cache with predefined state (which means already existing artifacts) to test particular scenarios.
Answered By - khmarbaise
Answer Checked By - Terry (JavaFixing Volunteer)