How do I get Gradle to shut up about TestNG tests?

I’m using Gradle to build and run tests that use TestNG. When I run the tests, Gradle was presenting the log output from the tests in two ways I don’t like.

First, it printed out every time it starts a new test, like this:

Gradle suite > Gradle test > com.foo.Test.test STARTED

I didn’t want that, so I did this:

events “STANDARD_ERROR”

(instead of events “started”, “passed”, “skipped”, “failed”, “standardOut”, “standardError”)

So now Gradle only echoes my stderr, but it also announces what it’s going, with a line like this:

Gradle suite > Gradle test STANDARD_ERROR

Can I get it to just pass the output through to the console without telling me that it’s doing so?

Also, either Gradle or TestNG is printing out lines like this:

Running test: test method […blah blah blah…]

And I don’t really want those, either. Do those come from Gradle, and can I get rid of them?

1 Like

Any suggestions about this? I can’t be the only person ever who has wanted Gradle to be less verbose when running tests, can I?

1 Like

Don’t use the built in logging and use your own output listener to forward error output:

https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/groovy/org/gradle/api/tasks/testing/Test.java#L587-587

1 Like

Thanks, I’ll give that a try.

Well, I tried it, but it’s not doing what I hoped. My listener is getting called. But it’s not called on whatever causes these sort of events to be logged:

My Tests > My Tests STANDARD_OUT

And the standard out is still being printed to the screen even before my listener is called. I imagine this is because I’m just adding the listener, not replacing whatever listener is already in place, as the name of the method (addTestOutputListener) would imply.

Any ideas how to override either or both of those?

Thanks,
Todd.

1 Like

Sorry for necroing, but @luke_daley’s tip fixed it for me. I couldn’t find this solution anywhere else.

@ToddBradley, you probably want to remove your test.testLogging.showStandardStreams = true or explicitly set it to false