HTML Reporter
When using JUnit XML, we can generate XML results from tests that are able to produce output with nested tests. Unfortunately, Gradle generates its HTML reports with the results it has in-memory, which doesn't support nested tests, and it doesn't seem to be able to fetch results from a different XML.
To solve this, Kotest has a listener that is able to generate HTML reports based on the XML reports that are generated by JUnit XML.
The following module is needed: io.kotest:kotest-extensions-htmlreporter
in your build. Search maven central for latest version here.
In order to use it, we simply need to add it as a listener through project config.
class ProjectConfig : AbstractProjectConfig() {
override val specExecutionOrder = SpecExecutionOrder.Annotated
override fun extensions(): List<Extension> = listOf(
JunitXmlReporter(
includeContainers = false,
useTestPathAsName = true,
),
HtmlReporter()
)
}
Notice that we also add JunitXmlReporter
. This will generate the necessary XML reports, used to generate the HTML reports.
There's no additional configuration needed, it should simply start generating HTML reports.
By default, it stores reports in path/to/buildDir/reports/tests/test
but this can be modified by changing the parameter
outputDir
.