Gradle swallowing System.out

4,538 views
Skip to first unread message

Tim Fox

unread,
Aug 1, 2012, 1:34:45 PM8/1/12
to ve...@googlegroups.com
Another productivity killer which we need to find a solution to, if we're going to stick with Gradle, is the way it swallows System.out from tests. (Well.. it goes to the output file, but not to the console).

This is irrespective of whether you have the following:

testLogging.showStandardStreams = true

in your build.gradle

I (and other users) use System.out all the time for quick one line debugging of tests. It's a must that this works as expected.




Jon Brisbin

unread,
Aug 1, 2012, 2:16:26 PM8/1/12
to ve...@googlegroups.com
basically:

apply plugin: 'java' // adds 'test' task

test {
  //configuring a system property for tests
  systemProperty 'some.prop', 'value'

  //tuning the included/excluded tests
  include 'org/foo/**'
  exclude 'org/boo/**'

  //makes the standard streams (err and out) visible at console when running tests
  testLogging.showStandardStreams = true


The Java plugin is worth including in your build. 

All you have to do to get the available tasks is run "./gradlew tasks" which gives the tasks and their documentation.

jb

Tim Fox

unread,
Aug 1, 2012, 2:32:58 PM8/1/12
to ve...@googlegroups.com
Jon - not sure I follow.. Are you suggesting a way to prevent Gradle from swallowing System.out?

Joern Bernhardt

unread,
Aug 1, 2012, 2:33:43 PM8/1/12
to ve...@googlegroups.com

Hi Jon,

the line "testLogging.showStandardStreams = true" is inside the test { ... } block of the build.gradle already. As Tim said, System.out.println() still doesn't show up. You have to use System.err.println() as a workaround, if you need output from your test to debug.

-another jb

Pid

unread,
Aug 1, 2012, 3:02:46 PM8/1/12
to ve...@googlegroups.com
On 01/08/2012 19:16, Jon Brisbin wrote:
>
>> Another productivity killer which we need to find a solution to, if
>> we're going to stick with Gradle, is the way it swallows System.out
>> from tests. (Well.. it goes to the output file, but not to the console).
>>
>> This is irrespective of whether you have the following:
>>
>> testLogging.showStandardStreams = true
>>
>> in your build.gradle
>>
>> I (and other users) use System.out all the time for quick one line
>> debugging of tests. It's a must that this works as expected.

Upgrade the Gradle version in gradle.properties to 1.1.

http://www.gradle.org/docs/current/release-notes#test-logging

There are some changes in this area, but not exactly the one you're
looking for. I'd still recommend inquiring as to whether there is a bug
here or not.


p

> basically:
>
> apply plugin: 'java' // adds 'test' task
>
> test {
> //configuring a system property for tests
> systemProperty 'some.prop', 'value'
>
> //tuning the included/excluded tests
> include 'org/foo/**'
> exclude 'org/boo/**'
>
> //makes the standard streams (err and out) visible at console when running tests
> testLogging.showStandardStreams = true
>
>
> http://gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html
>
> The Java plugin is worth including in your build.
>
> All you have to do to get the available tasks is run "./gradlew tasks"
> which gives the tasks and their documentation.
>
> jb
>
> --
> You received this message because you are subscribed to the Google
> Groups "vert.x" group.
> To post to this group, send an email to ve...@googlegroups.com.
> To unsubscribe from this group, send email to
> vertx+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/vertx?hl=en-GB.


--

[key:62590808]

signature.asc

Jon Brisbin

unread,
Aug 1, 2012, 3:13:51 PM8/1/12
to ve...@googlegroups.com
From http://issues.gradle.org/browse/GRADLE-1966

"The test stdout was being logged at info level, which meant you needed to run with --info to see it. This has been changed so that now the test stdout is logged at lifecycle level."

This fix is in 1.1-rc-1 so should be usable by upgrading to 1.1.

jb


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/R9jbiidi5KAJ.

Pid

unread,
Aug 1, 2012, 3:20:21 PM8/1/12
to ve...@googlegroups.com
On 01/08/2012 20:02, Pid wrote:
> On 01/08/2012 19:16, Jon Brisbin wrote:
>>
>>> Another productivity killer which we need to find a solution to, if
>>> we're going to stick with Gradle, is the way it swallows System.out
>>> from tests. (Well.. it goes to the output file, but not to the console).
>>>
>>> This is irrespective of whether you have the following:
>>>
>>> testLogging.showStandardStreams = true
>>>
>>> in your build.gradle
>>>
>>> I (and other users) use System.out all the time for quick one line
>>> debugging of tests. It's a must that this works as expected.
>
> Upgrade the Gradle version in gradle.properties to 1.1.

Actually, that didn't work for me just now, not sure why, but in
gradle/gradle-wrapper.properties...

I changed:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-bin.zip

to:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip
signature.asc

Pid

unread,
Aug 1, 2012, 3:26:41 PM8/1/12
to ve...@googlegroups.com
On 01/08/2012 20:13, Jon Brisbin wrote:
> From http://issues.gradle.org/browse/GRADLE-1966
>
> "The test stdout was being logged at info level, which meant you needed
> to run with --info to see it. This has been changed so that now the test
> stdout is logged at lifecycle level."
>
> This fix is in 1.1-rc-1 so should be usable by upgrading to 1.1.

Actually, Jon, you may be right. There's definitely some other output now.


p
>> <mailto:ve...@googlegroups.com>.
>> To unsubscribe from this group, send email to
>> vertx+un...@googlegroups.com
>> <mailto:vertx+un...@googlegroups.com>.
>> For more options, visit this group at
>> http://groups.google.com/group/vertx?hl=en-GB.
>
> --
> You received this message because you are subscribed to the Google
> Groups "vert.x" group.
> To post to this group, send an email to ve...@googlegroups.com.
> To unsubscribe from this group, send email to
> vertx+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/vertx?hl=en-GB.


--

[key:62590808]

signature.asc
Reply all
Reply to author
Forward
0 new messages