Log output from custom test runner Immediately

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.

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);
    }
 }