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?
Asked
Active
Viewed 4.6k times
46

smeeb
- 27,777
- 57
- 250
- 447
1 Answers
79
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
.

Peter Niederwieser
- 121,412
- 21
- 324
- 259
-
9Thanks @Peter Niederwieser (+1) - I think you are referring to [this link](http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:reports) 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?!?** – smeeb Sep 21 '14 at 21:44
-
3Click the next link (`TestTaskReports`). What's missing in my answer that caused you not to accept it? – Peter Niederwieser Sep 21 '14 at 22:05
-
2Thanks 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). – smeeb Sep 21 '14 at 23:14
-
Usually these things are documented in the DSL reference, but sometimes they aren't. – Peter Niederwieser Sep 22 '14 at 01:11
-
15Anyone knows how this would be for android gradle scripts ? – slott Apr 20 '16 at 14:17
-
6This doesn't seem to have any effect under JUnit 5, even for JUnit 4-based tests. – David Moles Oct 17 '17 at 23:50
-
4where do I place this? – Pedro Rodrigues Nov 04 '18 at 02:13
-
this worked for me after long day of search (my project is kotlin + spring boot + gradle + Junit -jupiter) – Chandrakant Audhutwar Jan 06 '23 at 09:25