title: Aggregate several JaCoCo .exec files into a single Coverage report with Gradle
body: <p><strong>Situation</strong>
  I'm working on a Spring Boot application that is coming along nicely, but the build-test cycle takes too long to be practical in a plain Dev environment.</p>
  <p>So, I recently decided to split-up my unit-tests and integration tests. The integration tests are based on Cucumber whereas the unit tests are plain JUnit 5 tests.</p>
  <p>For this I used the Gradle plugin <code>org.unbroken-dome.test-sets</code> which nicely creates the relevant sourceSets etc.</p>
  <pre><code>testSets {
      intTest { dirName = 'int-test' }
  }
  </code></pre>
  <p>Everything is working nicely and my tests are executing as intended. The unit tests are still executed when I do a build and the integration tests are executed when I call `gradlew intTest'. This is by design, as I don't want to execute all tests all the time.</p>
  <p>After running the tests, I also have a <code>jacoco/test.exec</code> file and a <code>jacoco/inttest.exec</code> file. All by design and as advertised by the test-sets plugin.</p>
  <p><strong>Problem</strong>
  Here's my problem. When I had all my tests still in the test-SourceSet, so before the split and with only the <code>test.exec</code> file generated, JaCoCo reported a coverage of around 75%. But now that I have split up the tests and having the <code>test.exec</code> and <code>intTest.exec</code> files, JaCoCo only reports a coverage of 15%, which is about right considering the extent of my unit tests and integration tests.</p>
  <p><strong>Question</strong>
  How can I get JaCoCo to use both the <code>test.exec</code> and the <code>intTest.exec</code> files to report the coverage and allow for the coverage verification task to consider both again?</p>
  <p><strong>Relevant Code</strong>
  Here is some of the relevant code:
  jacoco.gradle</p>
  <pre><code>apply plugin: 'java'
  apply plugin: 'jacoco'
  
  // -----------------------------------------------------------
  //
  // JaCoCo
  dependencies {
      implementation &quot;org.jacoco:org.jacoco.agent:${jacocoToolVersion}:runtime&quot;
  }
  
  jacoco {
      toolVersion = &quot;${jacocoToolVersion}&quot;
  }
  
  jacocoTestReport {
      dependsOn test
      reports {
          xml.enabled false
          csv.enabled true
          html.destination file(&quot;${buildDir}/reports/jacoco/Html&quot;)
          csv.destination file(&quot;${buildDir}/reports/jacoco/jacoco.csv&quot;)
      }
  }
  
  jacocoTestCoverageVerification {
      violationRules {
          rule {
              limit {
                  minimum = minCodeCoverage
              }
          }
      }
  }
  
  check.dependsOn jacocoTestCoverageVerification
  </code></pre>
  <p>Snippet from build.gradle:</p>
  <pre><code>tasks.withType(Test) {
      useJUnitPlatform()
      testLogging {
          events &quot;passed&quot;, &quot;skipped&quot;, &quot;failed&quot;
      }
      testLogging.showStandardStreams = true
      reports {
          junitXml.enabled = true
          html.enabled = true
      }
  }
  </code></pre>
  <p>and</p>
  <pre><code>testSets {
      intTest { dirName = 'int-test' }
  }
  
  intTest.mustRunAfter test
  check.dependsOn intTest
  
  test {
      systemProperties System.getProperties()
  
      finalizedBy jacocoTestReport
  }
  </code></pre>
  <p>Thanks in advance for helping me out or pointing me into the right direction.</p>