Tests running twice when using cobertura and maven site plugin
I am using maven and cobertura site plugin together to run unit tests and generate a report. Everything works fine, but the only problem is that all unit tests are running twice.
I tried to install forkMode
both never
for maven-site-plugin
, but even then I ran into the same problem.
Any help would be appreciated.
My team: mvn cobertura:cobertura -Dcobertura.report.format=html
My pom:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<aggregate>false</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<instrumentation>
<excludes>
<exclude>**/test/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<targetJdk>1.6</targetJdk>
<linkXref>true</linkXref>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<format>xml</format>
<aggregate>true</aggregate>
<verbose>true</verbose>
<rulesets>
<ruleset>favorites.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</plugins>
</reporting>
source to share
I believe this is normal behavior.
You are using two excellent reports that are based on the same:
- the test report requires the test to run but does not include coverage.
- coverage report requires the test to run from .
But both reports do not know about each other, so it runs twice.
[UPDATE] after reading this mailing list , it says that you should disable the test (using skipTests ) preferably in the profile.
As for your command line, this will give:
mvn cobertura:cobertura -DskipTests -Dcobertura.report.format=html
Note that I was unable to get cobertura to work (got Encountered "final" "final") on line 106, column 12.) with my project, so I don't know if it worked.
source to share
Tests will always run twice with cobertura-maven-plugin
.
If you need cobertura reports and want the tests to run only once, you can try the plugin qualinsight-mojo-cobertura-core
. You will find the documentation on the project page: https://github.com/QualInsight/qualinsight-mojo-cobertura .
source to share