mvn test configuration, spring context in subprojects
Hi,
I create a simple maven example with two subprojects.
\moduleA\pom.xml
\moduleA\src\main\java\ca\spring\test\SomeBean.jav a
\moduleA\src\main\java\ca\spring\test\SomeBeanImpl .java
\moduleA\src\main\resources\log4j.properties
\moduleA\src\main\resources\moduleA-config.xml
My moduleB depends of moduleA.
SomeBeanTest.java try to find “someBean” declaration and for that it use system-test-config.xml which reference moduleB-config.xml where I import moduleA-config.xml.
When I execute my test in Eclipse, the test runs fine, but when I execute it in cmd, my test fail simply because he can’t find moduleA-config.xml even if I install my modules first (mvn install).
Adding a dependency to junit in my parent pom solved my problem:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
In fact, without this dependency, all my annotations (like @Test, @Configuration …) are ignored when we execute “mvn test” in command line.