Registration when testing through Gradle

When testing, Gradle appears to redirect stdout / stderr to project_dir/build/reports/tests/index.html . Is there a way to avoid this redirect and print the contents to the console instead?

Additional Information:

  • This is a Scala 2.9.1 project.
  • I am using slf4s for logging.
+63
java scala logging gradle
Feb 20 '12 at 5:23
source share
5 answers
 apply plugin : 'java' test { testLogging.showStandardStreams = true } 

http://gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html

This requires the current version of gradle. I assume that the Scala tests run as part of the Java test task.

+77
Feb 20 2018-12-12T00:
source share

I also use ( testLogging.exceptionFormat = 'full' ):

 test { testLogging.showStandardStreams = true testLogging.exceptionFormat = 'full' } 

Good to see more from stacktrace

+19
Feb 17 '16 at 13:13
source share

For Android Gradle Files

If you are in the android Gradle file (if apply plugin: 'com.android.application' is at the top of the build.gradle file)

Then paste this into build.gradle

 // Test Logging tasks.withType(Test) { testLogging { events "standardOut", "started", "passed", "skipped", "failed" } } 
+16
Feb 23 '17 at 20:42 on
source share

As @roby answered:

adding the following code to your build.gradle

 apply plugin : 'java' test { testLogging.showStandardStreams = true } 

Attention!

You need to run gradle test or build with the clean command added.

 ./gradlew clean test or ./gradlew clean build 

Hope this works.

+15
May 11 '16 at 4:15
source share

It works:

 test { testLogging { showStandardStreams = true } } 
+8
Oct 31 '16 at 8:46
source share



All Articles