{"id":13734379,"url":"https://github.com/radarsh/gradle-test-logger-plugin","last_synced_at":"2025-05-15T03:06:49.366Z","repository":{"id":23472176,"uuid":"98467531","full_name":"radarsh/gradle-test-logger-plugin","owner":"radarsh","description":"A Gradle plugin for printing beautiful logs on the console while running tests","archived":false,"fork":false,"pushed_at":"2024-12-16T13:38:26.000Z","size":7979,"stargazers_count":859,"open_issues_count":33,"forks_count":38,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-04-14T03:07:56.755Z","etag":null,"topics":["ansi-colors","colours","console","gradle","gradle-plugin","groovy","hacktoberfest","logger","test"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/radarsh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-26T21:32:04.000Z","updated_at":"2025-03-28T13:02:53.000Z","dependencies_parsed_at":"2025-01-14T23:15:39.217Z","dependency_job_id":null,"html_url":"https://github.com/radarsh/gradle-test-logger-plugin","commit_stats":{"total_commits":200,"total_committers":12,"mean_commits":"16.666666666666668","dds":"0.20999999999999996","last_synced_commit":"1835aec91cf53b2dd68a89493ee9890c7c9cdf7e"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radarsh%2Fgradle-test-logger-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radarsh%2Fgradle-test-logger-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radarsh%2Fgradle-test-logger-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radarsh%2Fgradle-test-logger-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/radarsh","download_url":"https://codeload.github.com/radarsh/gradle-test-logger-plugin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264766,"owners_count":22041793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi-colors","colours","console","gradle","gradle-plugin","groovy","hacktoberfest","logger","test"],"created_at":"2024-08-03T03:00:55.178Z","updated_at":"2025-05-15T03:06:44.346Z","avatar_url":"https://github.com/radarsh.png","language":"Groovy","funding_links":[],"categories":["Plugins","Credits"],"sub_categories":["Testing"],"readme":"# Gradle Test Logger Plugin\n\n[![Gradle Plugin Portal](https://img.shields.io/gradle-plugin-portal/v/com.adarshr.test-logger?label=version\u0026style=flat-square\u0026logo=gradle)](https://plugins.gradle.org/plugin/com.adarshr.test-logger)\n[![CircleCI branch](https://img.shields.io/circleci/build/github/radarsh/gradle-test-logger-plugin/develop?label=circleci\u0026style=flat-square\u0026logo=circleci)](https://circleci.com/gh/radarsh/gradle-test-logger-plugin/tree/develop)\n[![AppVeyor branch](https://img.shields.io/appveyor/build/radarsh/gradle-test-logger-plugin/develop?label=appveyor\u0026style=flat-square\u0026logo=appveyor)](https://ci.appveyor.com/project/radarsh/gradle-test-logger-plugin/branch/develop)\n[![Coveralls branch](https://img.shields.io/coveralls/github/radarsh/gradle-test-logger-plugin/develop?\u0026style=flat-square\u0026logo=coveralls)](https://coveralls.io/github/radarsh/gradle-test-logger-plugin?branch=develop)\n[![License](https://img.shields.io/github/license/radarsh/gradle-test-logger-plugin?style=flat-square\u0026logo=apache)](https://github.com/radarsh/gradle-test-logger-plugin/blob/develop/LICENSE)\n[![Twitter Follow](https://img.shields.io/twitter/follow/radarsh?label=%40radarsh\u0026logo=twitter\u0026style=flat-square)](https://twitter.com/intent/follow?screen_name=radarsh)\n\nA Gradle plugin for printing beautiful logs on the console while running tests.\n\n## Screenshots\n\n### Standard theme\n\n![Standard theme](docs/images/standard.gif)\n\n### Mocha theme\n\n![Mocha theme](docs/images/mocha.gif)\n\nScroll down for more themes and customisation options or visit the [screenshots page](docs/SCREENSHOTS.md) for more demos.\n\n## Usage\n\n### Using the plugins DSL\n\n```groovy\nplugins {\n    id 'com.adarshr.test-logger' version '4.0.0'\n}\n```\n\n### Using legacy plugin application\n\n```groovy\nbuildscript {\n    repositories {\n        maven {\n            url 'https://plugins.gradle.org/m2/'\n        }\n    }\n    dependencies {\n        classpath 'com.adarshr:gradle-test-logger-plugin:4.0.0'\n    }\n}\n\napply plugin: 'com.adarshr.test-logger'\n```\n\n### Compatibility matrix\n\n| Test logger version | Minimum Gradle version |\n|---------------------|------------------------|\n| 1.x                 | 4.x                    |\n| 2.x                 | 5.x                    |\n| 3.x                 | 6.5                    |\n| 4.x                 | 7.6                    |\n\n## Configuration\n\nThe plugin registers an extension called `testlogger` (all lowercase and one word) at project level\nas well as for each task of type [`Test`](https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html).\n\nThe following shows the complete default configuration applied when you configure nothing.\n\n```groovy\ntestlogger {\n    theme 'standard'\n    showExceptions true\n    showStackTraces true\n    showFullStackTraces false\n    showCauses true\n    slowThreshold 2000\n    showSummary true\n    showSimpleNames false\n    showPassed true\n    showSkipped true\n    showFailed true\n    showOnlySlow false\n    showStandardStreams false\n    showPassedStandardStreams true\n    showSkippedStandardStreams true\n    showFailedStandardStreams true\n    logLevel 'lifecycle'\n}\n```\n\n### Project vs task level configuration\n\nSettings configured at the project level can be overridden by redefining them at task level. Settings\nnot defined at task level will inherit project level values. Consider the below configuration.\n\n```groovy\ntestlogger {\n    theme 'mocha' // project level\n    slowThreshold 5000\n}\n\ntest {\n    testlogger {\n        theme 'standard-parallel' // task level\n    }\n}\n```\n\nIn the above example, the effective theme will be `standard-parallel` and `slowThreshold` will be `5000` whereas rest of\nthe settings will retain their default values.\n\n### Overriding settings at runtime\n\nAll the above settings can either be specified in `build.gradle` or be set at runtime using system properties or both.\nFor instance, we could have `theme` set to `mocha` in the build file but it can be overridden to be `standard` at runtime\nby using `-Dtestlogger.theme=standard` on the command line. Since they are system properties we have a number of ways of\nspecifying them including `JAVA_OPTS` and `gradle.properties`.\n\n- The convention used for determining the name of the system property is `testlogger.\u003cconfiguration setting\u003e`.\n- System property overrides will be applied after combining task and project level settings.\n- Specifying a system property override will apply the same setting for all tasks, regardless of any configuration\ndefined in the build file.\n\n### Switch themes\n\n```groovy\ntestlogger {\n    theme 'mocha'\n}\n```\n\nThe following themes are currently supported:\n\n1. `plain` - displays no colours or Unicode symbols\n2. `standard` - displays colours but no Unicode symbols\n3. `mocha` - similar to what [Mocha's](https://github.com/mochajs/mocha) [spec reporter](https://mochajs.org/#spec)\nprints, with colours and Unicode symbols\n4. `plain-parallel` - similar to the `plain` theme but supports parallel test execution\n5. `standard-parallel` - similar to the `standard` theme but supports parallel test execution\n6. `mocha-parallel` - similar to the `mocha` theme but supports parallel test execution\n\n### Hide exceptions\n\nBy default, the `showExceptions` flag is turned on. This shows why the tests failed including the location of the\nfailure. Of course, you can switch off this slightly more verbose logging by setting `showExceptions` to `false`.\n\n```groovy\ntestlogger {\n    showExceptions false\n}\n```\n\n### Hide exception stack traces\n\nSometimes it is useful to just see the exception message instead of the stack trace. This can be configured by\nsetting `showStackTraces` to `false`.\n\n```groovy\ntestlogger {\n    showStackTraces false\n}\n```\n\n### Hide exception causes\n\nThe default behaviour of the plugin is to print all the causes of the exception. If it is too verbose to your taste, you \ncan turn it off by setting `showCauses` to `false`.\n\n```groovy\ntestlogger {\n    showCauses false\n}\n```\n\n### Show full exception stack traces\n\nJust like Gradle itself, by default only the last frame that matches the test class's name in a stack trace is printed. For vast\nmajority of cases, that is sufficient. Sometimes, it is useful to remove this filtering in order to see the entirety of the stack\ntrace. This can be done by setting `showFullStackTraces` to `true`.\n\n```groovy\ntestlogger {\n    showFullStackTraces true\n}\n```\n\n### Define slow threshold\n\nTests that are too slow will have their duration logged. However, \"slow\" is a relative terminology varying widely\ndepending on the type of tests being executed, environment, kind of project and various other factors. Therefore you\ncan define what you consider as slow to suit your needs.\n\n```groovy\ntestlogger {\n    slowThreshold 5000\n}\n```\n\nThe default value of `slowThreshold` is `2` seconds. So all tests that take longer than a second to run will have their\nactual execution time logged.\n\nIf you want to turn off the logging of time taken completely, simply set the threshold to a very large value.\n\nPlease note that in themes that support colours, the duration is displayed using a warning style if it is greater than\nhalf the slow threshold. For instance, if `slowThreshold` is 5 seconds any tests that take longer than 2.5 seconds to\nrun would have their durations logged using a warning style and those that take longer than 5 seconds to run using an\nerror style.\n\n### Hide summary\n\nBy default, a useful summary containing a breakdown of passing, failing and skipped tests along with the total time\ntaken to execute all the tests is shown. Of course, you can disable this if you prefer a more succinct output.\n\n```groovy\ntestlogger {\n    showSummary false\n}\n```\n\n### Show simple names\n\nIf you don't like seeing long, fully-qualified class names being used for displaying the test suite names, you can choose to\nshow only [simple names](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getSimpleName--) by setting the below flag to true.\n\n```groovy\ntestlogger {\n    showSimpleNames true\n}\n```\n\n### Show standard streams\n\nThe display of standard output and error streams alongside the test logs can be controlled using the below configuration.\n\n```groovy\ntestlogger {\n    showStandardStreams true\n}\n```\n\n### Filter standard streams\n\nIf the display standard output and error streams is enabled, it can often produce too much output to overwhelm anyone.\nFortunately, we can filter this output based on the type of the test result.\n\n```groovy\ntestlogger {\n    showStandardStreams true\n    showPassedStandardStreams false\n    showSkippedStandardStreams false\n    showFailedStandardStreams true\n}\n```\n\nAll the three filter flags are enabled by default. In other words, the standard stream output is not filtered if\n`showStandardStreams` is enabled but none of the filter flags are configured.\n\nIf `showStandardStreams` is set to `false`, the filter flags don't have any effect.\n\n### Filter test results\n\nSometimes it is useful to hide test results of a certain type. For instance, if an application has hundreds of tests, the\nsheer volume of the output produced by passing tests could be enough to bury any valuable test failures. Similarly there\nmight be a need to hide skipped tests or in rare instances even the failed ones.\n\nWe can perform test result filtering by using the below settings.\n\n```groovy\ntestlogger {\n    showPassed false\n    showSkipped false\n    showFailed true\n    showOnlySlow false\n}\n```\n\nBy default the flags `showPassed`, `showSkipped` and `showFailed` are turned on while `showOnlySlow` will be off. If you have chosen to display standard streams by setting\n`showStandardStreams` flag to `true`, any output produced by filtered out tests will not be displayed.\n\n### Change log level\n\nBy default, results are output at the standard `lifecycle` [Gradle log level](https://docs.gradle.org/current/userguide/logging.html#sec:choosing_a_log_level). This can be configured with `logLevel`. For example, the following will output\nthe results even on runs with `--quiet`.\n\n```groovy\ntestlogger {\n    logLevel 'quiet'\n}\n```\n\n### Relationship between `testlogger` and `Test.testLogging`\n\nWhere possible, the plugin's `testlogger` extension tries to react to equivalent properties of Gradle's `Test.testLogging` \nextension. However, if a value is explicitly configured under the `testlogger` extension, the plugin __does not__ react to the\ncorresponding property of `Test.testLogging`. The below table demonstrates this in more detail.\n\n| Property                  | `Test.testLogging` value              | `testlogger` value     | Effective value |\n|---------------------------|---------------------------------------|------------------------|---------------- |\n| `showStandardStreams`     | `true`                                | not configured         | `true`          |\n| `showStandardStreams`     | `true`                                | `false`                | `false`         |\n| `showStandardStreams`     | `false`                               | `true`                 | `true`          |\n| `showExceptions`          | `true`                                | not configured         | `true`          |\n| `showExceptions`          | `true`                                | `false`                | `false`         |\n| `showExceptions`          | `false`                               | `true`                 | `true`          |\n| `showStackTraces`         | `true`                                | not configured         | `true`          |\n| `showStackTraces`         | `true`                                | `false`                | `false`         |\n| `showStackTraces`         | `false`                               | `true`                 | `true`          |\n| `showFullStackTraces`     | `testLogging.exceptionFormat = FULL`  | not configured         | `true`          |\n| `showFullStackTraces`     | `testLogging.exceptionFormat = SHORT` | not configured         | `false`         |\n| `showFullStackTraces`     | `testLogging.exceptionFormat = FULL`  | `false`                | `false`         |\n| `showFullStackTraces`     | `testLogging.exceptionFormat = SHORT` | `true`                 | `true`          |\n| `showCauses`              | `true`                                | not configured         | `true`          |\n| `showCauses`              | `true`                                | `false`                | `false`         |\n| `showCauses`              | `false`                               | `true`                 | `true`          |\n\nIn other words, an explicitly configured `testlogger` property, despite it being `false`, takes precedence over any \nvalue of `Test.testLogging`.\n\n## Kotlin DSL\n\nIf you are using the Kotlin DSL, the syntax of `testlogger` extension DSL changes slightly. The following shows the default\nconfiguration properties using Kotlin DSL style.\n\n```kotlin\ntestlogger {\n    theme = ThemeType.STANDARD\n    showExceptions = true\n    showStackTraces = true\n    showFullStackTraces = false\n    showCauses = true\n    slowThreshold = 2000\n    showSummary = true\n    showSimpleNames = false\n    showPassed = true\n    showSkipped = true\n    showFailed = true\n    showOnlySlow = false\n    showStandardStreams = false\n    showPassedStandardStreams = true\n    showSkippedStandardStreams = true\n    showFailedStandardStreams = true\n    logLevel = LogLevel.LIFECYCLE\n}\n```\n\nOne gotcha about Kotlin DSL is that if you have subprojects that are trying to use a different testlogger setting compared to\nthe parent project, the syntax changes slightly.\n\n```kotlin\nsubprojects {\n\n    apply {\n        plugin(\"com.adarshr.test-logger\")\n    }\n\n    configure\u003cTestLoggerExtension\u003e {\n        theme = ThemeType.STANDARD\n        showExceptions = true\n        ...\n    }\n}\n```\n\n## FAQ\n\n### Does it work on Windows?\n\nMostly. The `standard` and `plain` themes work out of the box but you might have to make a few modifications to your\nsystem settings to see Unicode symbols when using the `mocha` theme.\n\n1. Set or update `JAVA_OPTS` with the system property `-Dfile.encoding=UTF-8`\n2. Change the terminal code page to 65001 by executing `chcp 65001`\n\n### How to disable colours and Unicode symbols at runtime such as on Jenkins consoles?\n\nYou can switch off ANSI control characters and Unicode symbols by adding `--console=plain` to your Gradle command line.\n\n### Does it support parallel test execution?\n\nYes. You will need to switch to a suitable parallel theme though. This can be one of `plain-parallel`, `standard-parallel` or\n`mocha-parallel`. The parallel themes are specially designed to work with a setting of\n[`maxParallelForks`](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:maxParallelForks)\ngreater than 1. They achieve this by sacrificing the ability to group tests and thus some readability is lost.\n\n### Can this plugin co-exist with junit-platform-gradle-plugin?\n\nDue to certain unknown reasons, `junit-platform-gradle-plugin` is incompatible with `gradle-test-logger-plugin`. If you are still\nusing `junit-platform-gradle-plugin`, it might be worth noting that this plugin was [deprecated in JUnit Platform 1.2 and removed\nfrom JUnit Platform 1.3](https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle).\n\nThe test logger plugin however, is fully compatible with the [Gradle native way](https://docs.gradle.org/current/userguide/java_testing.html#using_junit5) of\nusing JUnit 5.\n\n### I see the test output twice. How can I fix it?\n\nExample:\n\n```text\n\u003e Task :myTest\norg.project.MyTest\n  Test test() FAILED\n  org.opentest4j.AssertionFailedError: expected: \u003cOptional[String]\u003e but was: \u003cOptional.empty\u003e\n\n\nMyTest \u003e test() FAILED\n    org.opentest4j.AssertionFailedError: expected: \u003cOptional[String]\u003e but was: \u003cOptional.empty\u003e\n        at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)\n```\n\nThen, you still have `testLogging` of gradle enabled. Example setting:\n\n\n```groovy\n  testLogging {\n    events = [\"FAILED\"]\n    exceptionFormat \"full\"\n  }\n```\n\nSolution: Remove that setting from your `build.gradle`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradarsh%2Fgradle-test-logger-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradarsh%2Fgradle-test-logger-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradarsh%2Fgradle-test-logger-plugin/lists"}