Showing posts with label testing. Show all posts
Showing posts with label testing. Show all posts

Specific Cobertura version in Maven-cobertura-plugin

I found this blog post by Brian Fox explaining how to override a plugin's dependencies.
This allowed me to configure the maven-cobertura-plugin to use a specific cobertura version (1.9.1.1 being the latest one available in the central maven repository), instead of the one configured by the plugin itself (1.9).
As stated by Brian, as long as the newly introduced version's API is compatible with the original one, there should be no problem.

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>1.9.1.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>

Maven: Spring-Test 2.5.x & JUnit 4

I ran into this weird problem today while setting up an integration-testing module in my maven project: The Surefire-plugin seemed to ignore the JUnit4 annotations.
I found a Maven-Surefire issue (SUREFIRE-448) describing the same problem, but it is marked as irreproducible and proposes no solution.
After looking into the debug information (mvn clean test -X > log.txt), it turns out that Spring-Test has a dependency on JUnit 3.8.1, and this is causing my test classes to run as JUnit3 instead of JUnit4.
To fix this, simply exclude JUnit from the Spring-Test dependency:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.6</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>