I would like to see test results ( system.out/err, log messages from components being tested ) as they run in the same console I run:
gradle test
And not wait until tests are done to look at the test reports ( that are only generated when tests are completed, so I can't "tail -f" anything while tests are running )
'test' task does not work for Android plugin, for Android plugin use the following:
See the following: https://stackoverflow.com/a/31665341/3521637
As a follow up to Shubham's great answer I like to suggest using enum values instead of strings. Please take a look at the documentation of the TestLogging class.
If you have a
build.gradle.kts
written in Kotlin DSL you can print test results with (I was developing a kotlin multi-platform project, with no "java" plugin applied):Add this to
build.gradle
to stop gradle from swallowing stdout and stderr.It's documented here.
Merge of Shubham's great answer and JJD use enum instead of string
Disclaimer: I am the developer of the Gradle Test Logger Plugin.
You can simply use the Gradle Test Logger Plugin to print beautiful logs on the console. The plugin uses sensible defaults to satisfy most users with little or no configuration but also offers a number of themes and configuration options to suit everyone.
Examples
Standard theme
Mocha theme
Usage
Make sure you always get the latest version from Gradle Central.
Configuration
You don't need any configuration at all. However, the plugin offers a few options. This can be done as follows (default values shown):
I hope you will enjoy using it.