When running Gradle tests on Travis CI, the terminal is usually set to
dumb mode, so you get very plain looking output. However, Travis does allow for colors in their logs.
This Gradle script plugin formats the Gradle test output in a slightly colorful way (made for Travis CI but works in terminal). It also adds a summary at the end.
Add the ColoredOutput.gradle script to your project, for example at
At the top of your
build.gradle, reference it.
apply from: 'buildtools/ColoredOutput.gradle'
If you want Travis folding, you can enable it like so:
apply from: 'buildtools/ColoredOutput.gradle' project.ext.set("TRAVIS_FOLDING", true)
If you run your build on Travis you should now see colored output.
Additionally you will see colored output in the terminal.
How it works
This script makes use of Gradle’s TestListener class which provides methods that run before and after tests and test suites are run.
The script uses the results passed in
afterTest to render
✓ for success,
❌ for failure or
ಠ_ಠ for skipped tests.
At the end, the
afterSuite method renders a summary using various ANSI colors which Travis recognizes and renders.