# Log output from custom test runner Immediately

**URL:** <https://discuss.gradle.org/t/log-output-from-custom-test-runner-immediately/36215>\
**Category:** Help/Discuss\
**Created:** [May 24, 2020, 10:00am UTC](https://discuss.gradle.org/t/log-output-from-custom-test-runner-immediately/36215 "2020-05-24T10:00:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nestedsoftware](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/nestedsoftware/32/8544_2.png) [@nestedsoftware](https://discuss.gradle.org/u/nestedsoftware)\
**Post date:** [May 24, 2020, 10:00am UTC](https://discuss.gradle.org/t/log-output-from-custom-test-runner-immediately/36215/1 "2020-05-24T10:00:18Z")

</div>

I have a custom test runner for junit (as below). When I run my unit tests as gradle tasks, the output from this runner is only shown after the test starts (note the sleep). I would like for it to show up immediately (when the `run` method starts). So far, the only way I’ve found to make this work is to call `notifier.fireTestStarted(getDescription());` in the run method. Is there a better way to do this?

Note:I’ve also tried adding a listener in build.gradle with `onOutput` instead. However, this causes everything to get printed twice.

```java
public class MyRunner extends BlockJUnit4ClassRunner {

    public MyRunner(Class<?> klass) throws InitializationError {
        super(klass);
    }

    public void run(RunNotifier notifier) {
        //notifier.fireTestStarted(getDescription());
        System.out.println("We are about to sleep!");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("We are done sleeping!");
        super.run(notifier);
    }
 }

```
