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?
How to generate a Test Report. Gradle generates a Test Report automatically when it runs the entire Test Suite. To do the same, run ./gradlew test (or gradlew. bat test from Windows), or run the test Gradle task from your IDE.
By default, Gradle will run all tests that it detects, which it does by inspecting the compiled test classes. This detection uses different criteria depending on the test framework used. For JUnit, Gradle scans for both JUnit 3 and 4 test classes.
Parallel execution Yet Gradle will only run one task at a time by default, regardless of the project structure (this will be improved soon). By using the --parallel switch, you can force Gradle to execute tasks in parallel as long as those tasks are in different projects.
By default, JUnit tests generate simple report XML files for its test execution. These XML files can then be used to generate any custom reports as per the testing requirement. We can also generate HTML reports using the XML files.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With