8

I put the surefire and cobertura plugins in my pom.xml, but I can't configure them to work fine. Or cobertura doesn't run or the tests are executes twice.

So, how could I configure the plugins for they run together and just one time?

If I configure in this way, cobertura doesn't run:

<plugin>
<groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
</plugin>

If I configure in this way, the tests are executes twice:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.5.1</version>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>cobertura</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
</plugin>
Jens
  • 67,715
  • 15
  • 98
  • 113
joaosavio
  • 1,481
  • 3
  • 17
  • 20

2 Answers2

0

The tests will run twice - it is just the way it is. See Samuel's comment running junits and cobertura with maven

Community
  • 1
  • 1
Andre
  • 390
  • 3
  • 8
0

This is how I got it to work for tests with cobertura on and surefire off. Add this to your pom, or put in mvn options for -DuseSystemClassLoader=false

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <useSystemClassLoader>false</useSystemClassLoader>
                <testFailureIgnore>true</testFailureIgnore>
            </configuration>
        </plugin>