How to make Gradle build produce HTML test report instead of XML default?
Asked Answered
D

2

48

Currently I build my Gradle app by running gradle clean build. This exercises JUnit tests and produces XML test results in my project under build/test-results. I would like to configure my build.gradle file to produce HTML test results (instead of the XML default). Is this possible, if so, how?

Darg answered 21/9, 2014 at 20:31 Comment(0)
P
78
test {
    reports {
        junitXml.enabled = false
        html.enabled = true
    }               
}

To figure this out on your own, start from Test in the Gradle Build Language Reference, then drill down into (the type for) reports.

Phytology answered 21/9, 2014 at 20:59 Comment(9)
Thanks @Peter Niederwieser (+1) - I think you are referring to this link which I had already found prior to posting my question. The root problem is this: that link doesn't mention the junitXml.enabled or html.enabled properties at all...so how in the world is anybody supposed to know they exist?!?Darg
Click the next link (TestTaskReports). What's missing in my answer that caused you not to accept it?Phytology
Thanks again @Peter Niederwieser (+1) - I guess I'm just stunned that this isn't documented anywhere else besides API docs, which one then has to manually infer property names from (using Camel Casing).Darg
Usually these things are documented in the DSL reference, but sometimes they aren't.Phytology
Anyone knows how this would be for android gradle scripts ?Ariadne
This doesn't seem to have any effect under JUnit 5, even for JUnit 4-based tests.Husband
where do I place this?Selfsealing
this worked for me after long day of search (my project is kotlin + spring boot + gradle + Junit -jupiter)Antagonistic
In more recent versions of Gradle, the test and coverage (JaCoCo plugin) both use required instead of enabled. For example: html.required = trueFischer
T
0

According to the Gradle Test Reporting Docs, at least for Gradle version 8.10.2, an HTML based test report is automatically generated whenever the test task is run:

The Test task generates the following results by default:

• An HTML test report

• XML test results in a format compatible with the Ant JUnit report task — one that is supported by many other tools, such as CI servers

• An efficient binary format of the results used by the Test task to generate the other formats

I'm using Gradle with the application plugin using the JUnit 5 Jupiter platform for testing and whenever I run the test task the following test report gets generated and is accessible by opening app/build/reports/tests/test/index.html.

Terrieterrier answered 21/10, 2024 at 23:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.