I'm using cobertura maven plugin to produce report about test code coverage of my spring-based application. My unit tests configures as:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/testAppContext.xml")
public class TestCase extends TestBase
testAppContext.xml - Spring IOC config located at /src/test/resources/testAppContext.xml
And my cobertura's related pom.xml part is:
<build>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
<build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
When I make "mvn clean install" it works fine, but when I make "mvn site" - spring-based tests are failed because of "Failed to load ApplicationContext" with underlying "Injection of autowired dependencies failed", so I receive incorrect report about test coverage.
I assume this may be because testAppContext.xml is not on the classpath during "site" goal or something other. Any suggestion how to fix this problem?
Thank you for your help!