Kotest HTML Reporter
When using JUnit XML, tests with nested tests can generate XML results with output. Unfortunately, Gradle generates HTML reports using in-memory results that do not support nested tests, and it does not appear to be able to import results from another XML file.
To solve this problem, Kotest has a listener that can generate HTML reports based on XML reports generated by JUnit XML.
To use it, simply add it as a listener through project configuration.
class ProjectConfig : AbstractProjectConfig() {
override val specExecutionOrder = SpecExecutionOrder.Annotated
override fun extensions(): List<Extension> = listOf(
JunitXmlReporter(
includeContainers = false,
useTestPathAsName = true,
),
HtmlReporter()
)
}
Then add html.required.set(false) to the test task so Gradle does not generate its own HTML report.
tasks.test {
useJUnitPlatform()
reports {
html.required.set(false)
junitXml.required.set(false)
}
systemProperty("gradle.build.dir", project.buildDir)
}
Also add JunitXmlReporter. This creates the XML reports needed to generate the HTML report. No additional configuration is required; simply start generating the HTML report.
By default, reports are stored at /to/buildDir/reports/tests/test, but you can change this by modifying the outputDir parameter.