title: Cobertura on Jenkins Duplicate Test Runs
body: <p>I have a build that includes cobertura as part of my Jenkins run. However, I realize now that it is running all my tests twice. </p>
  
  <p>I have the project setup as a Maven project in Jenkins. and I had the goal to run set to: <code>clean coberture:cobertura install</code></p>
  
  <p>I had thought that the <code>install</code> portion of the command would simply run the remaining portions of the install goal, such as package. However, it reruns the compile and all the tests. This is despite the fact that there are already tests there.</p>
  
  <p>I've tried configuring different combinations of pre build and post build steps, but I keep running into issues. In some combinations, the build artifacts, such as jars, never get published on Jenkins. In other cases the test results are missing. </p>
  
  <p>I've thought that perhaps I need to remake the build as just a shell build. I think I could then run the command: <code>mvn clean cobertura:cobertura &amp;&amp; mvn install -Dmaven.test.skip=true</code></p>
  
  <p>I think this would do what I want. It would at least stop running all the tests twice.</p>
  
  <p>Is this the best approach or is there another way?</p>
  
  <p>This is how I am including Cobertura in my POM:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;parent&gt;
      &lt;groupId&gt;com.foo.bar&lt;/groupId&gt;
      &lt;artifactId&gt;my-parent&lt;/artifactId&gt;
      &lt;version&gt;1.2.1&lt;/version&gt;
    &lt;/parent&gt;
  
    &lt;groupId&gt;com.foo.bar.baz&lt;/groupId&gt;
    &lt;artifactId&gt;osom&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
    &lt;description&gt;TODO&lt;/description&gt;
  
  
    &lt;modules&gt;
      &lt;module&gt;module1&lt;/module&gt;
      &lt;module&gt;module2&lt;/module&gt;
      &lt;module&gt;module3&lt;/module&gt;
    &lt;/modules&gt;
  
    &lt;dependencies&gt;
    &lt;/dependencies&gt;
  
    &lt;build&gt;
  
      &lt;!-- To define the plugin version in your parent POM --&gt;
      &lt;pluginManagement&gt;
        &lt;plugins&gt;
          &lt;plugin&gt;
            &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
            &lt;artifactId&gt;findbugs-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.3&lt;/version&gt;
          &lt;/plugin&gt;
        &lt;/plugins&gt;
      &lt;/pluginManagement&gt;
  
  
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.7&lt;/source&gt;
            &lt;target&gt;1.7&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
  
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;goals&gt;
                &lt;goal&gt;test-jar&lt;/goal&gt;
              &lt;/goals&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
  
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.18&lt;/version&gt;
          &lt;configuration&gt;
            &lt;useUnlimitedThreads&gt;true&lt;/useUnlimitedThreads&gt;
            &lt;parallel&gt;suites&lt;/parallel&gt;
            &lt;reuseForks&gt;false&lt;/reuseForks&gt;
            &lt;includes&gt;
              &lt;include&gt;**/*Test.java&lt;/include&gt;
              &lt;include&gt;**/Test*.java&lt;/include&gt;
            &lt;/includes&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
    &lt;!-- use mvn cobertura:cobertura to generate cobertura reports --&gt;
    &lt;reporting&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.7&lt;/version&gt;
          &lt;configuration&gt;
            &lt;aggregate&gt;true&lt;/aggregate&gt;
            &lt;format&gt;xml&lt;/format&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/reporting&gt;
  &lt;/project&gt;
  </code></pre>