The test phase does not include packaging 
(https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
So `mvn tsst` only runs the tests for the specific module. If there is a 
dependency, it will not work as the dependency has not yet run the packaging 
step.

I think, your test is a kind of integration test, as you test the integration 
of your application with the other module.
Have you tried running `mvn verify` instead of `mvn test`? The verify phase is 
based on the packaging phase. So in your multi-module build, the 
dependency-module should be build, tested, and packaged first. Then the 
application-module should do run through the same lifecycle phases and find a 
packaged dependency-module for its (integration) testing.

You could see what happens in the different phases, with `mvn 
buildplan:list-phases`. 

Perhaps you would like to separate tests for the application-module, having 
unit tests for the internal units of work, and integration-tests running in the 
verify-phase only?

> On 3. Jan 2025, at 09:46, Claude Brisson <claude.bris...@gmail.com> wrote:
> 
> If I have the following multi-module structure:
> 
> parent-module
>   dependency-module
>   application-module
> 
> How to explicitly declare that application-module tests depend not only on 
> dependency-module, but also on its packaging as a jar file to be done?
> 
> application-module needs the file 
> dependency-module/target/dependency-module-x.y.jar to be present.
> 
> In application-module/pom.xml I have the dependency:
> 
>   <dependency>
>     <groupId>com.example</groupId>
>     <artifactId>dependency-module</artifactId>
>     <version>${project.version}</version>
>     <type>jar</type>
>     <scope>test</scope>
>   </dependency>
> 
> If I run:
> 
>    mvn clean && mvn package
> 
> everything goes fine since modules are processed in order. But if I run:
> 
>   mvn clean && mvn test
> 
> then no packaging will take place in dependency-module and the test will not 
> be able to resolve its dependency.
> 
> Thanks for your help.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

--
Gerd Aschemann --- Veröffentlichen heißt Verändern (Carmen Thomas)
+49/173/3264070 -- g...@aschemann.net -- http://www.aschemann.net

Reply via email to