api / org.gradle.api.tasks.testing / AbstractTestTask / onOutput

onOutput

open fun onOutput(closure: Closure<Any>): Unit

Adds a closure to be notified when output from the test received. A TestDescriptor and TestOutputEvent instance are passed to the closure as a parameter.

 apply plugin: 'java' test { onOutput { descriptor, event -> if (event.destination == TestOutputEvent.Destination.StdErr) { logger.error("Test: " + descriptor + ", error: " + event.message) } } } 

Parameters

closure - The closure to call.