Can I have a jar containing Springboot integration tests & use this jar in other modules to execute the common integration tests?
Asked
Active
Viewed 509 times
4
-
you could do this. I wouldn't recommend doing it this way though. – moonboy May 02 '17 at 17:29
-
1Possible duplicate of http://stackoverflow.com/questions/10496846/run-junit-tests-contained-in-dependency-jar-using-maven-surefire – heenenee May 03 '17 at 20:09
1 Answers
0
As stated here:
Maven projects already define a standard for a project's tests. And in my opinion it doesn't make sense to make a project dependent on its tests--if anything, tests would be dependent on the module under test, since tests use the module, but not vice-versa.
Though if you wish to do this anyway, to answer your question: yes it is possible. As described here:
There is a new way of running a test in Maven from another jar. from maven-surefire-plugin version 2.15 you can tell Maven to scan your test jars for tests and run them. You don't need to extract the tests jar. Just add a dependency to your test jar like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<dependenciesToScan>
<dependency>test.jar.group:test.jar.artifact.id</dependency>
</dependenciesToScan>
</configuration>
</plugin>

lax1089
- 3,403
- 3
- 17
- 37