I need to reference some JUnit Tests (src/test/java) from project B in the test package src/test/java of project A whereas B is a maven dependecy of A.
Is this even possible?
<dependency>
<groupId>XYZ</groupId>
<artifactId>B</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>test</scope>
</dependency>
Both projects are under my controll.
Thanks for your advice
Test reports are available in consumerBanking\target\surefire-reports folder. Maven compiles the source code file(s) and then tests the source code file(s).
You can produce a jar which will include your test classes and resources. To reuse this artifact in an other project, you must declare this dependency with type test-jar : <project>
Your pom in project B needs to include this plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Then, you can access it from project A like this:
<dependency>
<groupId>XYZ</groupId>
<artifactId>B</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Changing 'type' to test-jar allows you to access test classes from that dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With