Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacoco integration test report xml not generating #119

Open
adispennette opened this issue Apr 27, 2021 · 1 comment
Open

Jacoco integration test report xml not generating #119

adispennette opened this issue Apr 27, 2021 · 1 comment

Comments

@adispennette
Copy link

adispennette commented Apr 27, 2021

I have a multi module project using gradle kotlin DSL and I have configured the integration test set:

testSets {
        create("testIntegration") {
            dirName = "test-integration"
        }
    }

I have configured Jacoco:

jacoco {
        toolVersion = "0.8.6"
        reportsDir = file("$buildDir/reports/jacoco")
    }

    tasks.withType<JacocoReport> {
        afterEvaluate {
            classDirectories.setFrom(
                files(
                    classDirectories.files.map {
                        fileTree(it).apply {
                            val excludes: List<out String> = project.extra["excludes"] as List<out String>
                            exclude(excludes)
                        }
                    }
                )
            )
        }
        reports {
            xml.isEnabled = true
            csv.isEnabled = false
            html.destination = file("$buildDir/jacocoHtml")
        }
    }

but the only report that ever gets built is jacocoTestReport.xml
based on my configuration above I would expect an additional jacocoTestIntegrationReport.xml to be created as well.

I have tried a number of was to attempt to force it to generate the report but nothing seems to work.
In the sub-module I have added:

tasks.named<JacocoReport>("jacocoTestIntegrationReport") {
    val test = tasks.named<Test>("test")
    val testIntegration = tasks.named<Test>("testIntegration")
    executionData(test, testIntegration)
    reports {
        xml.isEnabled = true
        csv.isEnabled = false
        html.destination = file("$buildDir/jacocoHtml")
    }
}

Hoping that would do something but nothing is working.

It seems to me jacoco is working fine since it is outputting the junit test report but test-sets that is not properly providing the data for jacoco to generate a report.

I hope I am just missing something trivial but at this point I can not find it.

@brizzbuzz
Copy link

I think you are missing this

  tasks.withType<Test>() {
    useJUnitPlatform()
    finalizedBy(tasks.withType(JacocoReport::class))
  }

I didn't even need to add the custom jacocoTestIntegrationReport task.

I pasted most of my root gradle file here https://gist.github.com/rgbrizzlehizzle/f7da659474a4c657f24277955c882f92

It is for a multi module build and I don't do any jacoco / test-set config in any of the sub modules so this should get you where you need to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants