Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.5.1
-
Labels:None
-
Environment:Maven 3, Windows
-
Number of attachments :
Description
I am evaluating upgrading my projects to use Maven 3.x, and I started to notice that some of my unit tests are failing when run as part of Cobertura, even though the same tests would pass without issues when they run under the regular "test" or "surefire" phases. It turns out that some of my tests have some depend on some static setup, so they would require to be run in separate JVMs, and this is usually accomplished by using <forkMode>always</forkMode> as part of the configuration of the surefire plugin. This worked fine with earlier versions of Maven, but started to break when trying Maven 3.x.
To verify the issue, I ran the same "mvn site" command twice on the same POM, with different versions of Maven, and here is what I found out:
- When using Maven 2.2.1, I can see that starting a new test will result in spawning a new JVM (I verified that using ProcessExplorer).
- When using Maven 3.0, I can see that the same JVM is being reused across the different unit tests.
Here are some of the relevant snippets from my POM:
<!-- from the build part -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<forkMode>always</forkMode>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<!-- from the reporting part -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
I suspect that this has to do with the way the surefire plugin is being called from Cobertura.
I have the same problem. The fork configuration works with maven 2.2.1 but not with maven 3.0.