context of the question: I'm currently developing some java system library wich presents layer between data source and user buisnesslogic. To test its functionality, data provider(in my case it is data grid) must be launched every time a new test is processed.
so, to improve test execution performance, a test infrastructure was made in an independent maven module. It launches data source once and then just clears its contents for every new test.
the problem itself: Now there is a necessity to give buisnesslogic developers our test infrastructure because of the same performance reasons. But it can't be done that simple because test infrastructure contains some system components of our library.
So,
Suppose we have a module A with your library implementation, and a module B with some test infrastructure, that contains dependencies on that implementation.
the question: Is there a way we can make a module C with accesses only API from module A at compile time (tests and sources) and can use test infrastructure from module B?
The build manager is
Maven 3.3.3
Test are made using
JUnit 4.11
Java IDE is
IntelliJ IDEA
what i've tried:
I've tried to resolve this issue using different Maven scopes like this:
Module A pom dependencies:
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleAAPI</artifactId>
</dependency>
</dependencies>
Module B pom dependencies:
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleA</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
Module C pom dependencies:
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleB</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleAAPI</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
But, using provided means that we need to specify ModuleA on classpath when running tests from moduleC. Thats is OK, when using surefire plugin, but how to achieve the same when running tests from IDE?
Another possible option is to add runtime dependency on moduleA like this:
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleB</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleAAPI</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>my.group</groupId>
<artifactId>moduleA</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
But, using runtime scopes indicates that sources from moduleA will be accesible at test compile time (Introduction to the Dependency Mechanism). And I need only API to be accessible. There is already a question abuot some alternative scope:
Is there any alternative to these two options?
Aucun commentaire:
Enregistrer un commentaire