# Parallel test execution support for Gradle Test Logger Plugin

**URL:** <https://discuss.gradle.org/t/parallel-test-execution-support-for-gradle-test-logger-plugin/24977>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [December 1, 2017, 6:26pm UTC](https://discuss.gradle.org/t/parallel-test-execution-support-for-gradle-test-logger-plugin/24977 "2017-12-01T18:26:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adarshr](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/adarshr/32/6448_2.png) [@adarshr](https://discuss.gradle.org/u/adarshr)\
**Post date:** [December 1, 2017, 6:26pm UTC](https://discuss.gradle.org/t/parallel-test-execution-support-for-gradle-test-logger-plugin/24977/1 "2017-12-01T18:26:03Z")

</div>

I am the author of the [Gradle Test Logger Plugin](https://github.com/radarsh/gradle-test-logger-plugin) and I am [seeking help / suggestions](https://github.com/radarsh/gradle-test-logger-plugin/issues/8) for supporting Gradle’s parallel test execution in my plugin.

The plugin can be used to print beautiful logs on the console while tests are being executed. Typically the console output would look something like (colours stripped for simplicity):

```nohighlight
com.example.test.FirstSpec

    Test abc PASSED
    Test def SKIPPED
    Test ghi PASSED

com.example.test.SecondSpec

    Test jkl PASSED
    Test mno SKIPPED
    Test pqr PASSED

```

As you can see, the tests are grouped by suites. This is all fine and dandy as long as `maxParallelForks` is set to `1` (Gradle default). But when more than one fork is executing the tests, grouping isn’t deterministic anymore as the tests are executed in parallel and the output can become mixed up. So we may see `FirstSpec` executing tests `abc` and `def` followed by `SecondSpec` executing `jkl` and `mno` followed by `FirstSpec` executing tests `ghi` followed by `SecondSpec` executing `pqr`. Classic problem with parallel processing and grouping.

```nohighlight
com.example.test.FirstSpec

    Test abc PASSED
    Test def SKIPPED

com.example.test.SecondSpec

    Test jkl PASSED
    Test mno SKIPPED

com.example.test.FirstSpec

    Test ghi PASSED

com.example.test.SecondSpec

    Test pqr PASSED

```

I find that an output of the above form makes the grouping useless. To resolve this problem, I can think of two options but both have their limitations.

1. Trap all output in a collection (a map keyed by suite name) and render after executing the last test. While this would resolve the grouping issue, visually it’s not very elegant as no output would appear on the console until the last test is executed and suddenly a large volume of output may be produced. Looks like this approach is used by [mocha-parallel-tests](https://www.npmjs.com/package/mocha-parallel-tests).

2. Use a different theme (the plugin has a concept of themes which changes the style of the output) that doesn’t involve grouping when `maxParallelForks > 1`. For instance the new theme could render the output as follows:

I would like to get an opinion of the Gradle community regarding this problem and would also welcome any other suggestions. For example, if there is a way to get more information during the execution of forked tests in the Gradle API, that might prove invaluable too.

Thank you and appreciate your time.
