Hi,
I want to add a standardOutputListener to a task/project within a junit testcase. I do:
@Test
void testListenToSdtOut() {
def project = ProjectBuilder.builder().build()
project.tasks.add(name: ‘hello’) << {
println “running task”
}
Task task = project.tasks[‘hello’]
assert task
boolean outputCaptured
task.logging.addStandardOutputListener([onOutput: {line ->
println ‘output captured.’
outputCaptured = true
}] as StandardOutputListener)
task.execute()
assert outputCaptured
}
But my testcase stays red. I investigated within the sources that there is a NoOpLoggingManager that does nothing when I call ‘add*Listener()’ Is there a specific reason why this is done like this ? I think it would be nice if the Testcase could also listen to standard output messages from a task.
What do you think ?
thanks, detlef
PS - Im using milestone-8