Discussion:
Getting stdout messages on command line
lidia
2012-06-06 00:15:31 UTC
Permalink
Hi

I'm writing a utility to query test base for TestNG annotations, to list
tests that are part of a specific TestNG group. The trouble is, that when I
execute it through gradle all the messages written with System.out.println
are not displayed.

I searched online and found that this issue was fixed for *tests* only. I
added the following code to build.gradle, but it made no difference:

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

I also found, this workaround suggestion, but it doesn't work:

private static PrintStream echo = new PrintStream(new
FileOutputStream(FileDescriptor.out));
echo.println("Starting TestGroupScanner...");

Any pointers on how I can get anything printed to command line from gradle
appreciated.

Lidia

--
View this message in context: http://gradle.1045684.n5.nabble.com/Getting-stdout-messages-on-command-line-tp5709858.html
Sent from the gradle-user mailing list archive at Nabble.com.
Peter Niederwieser
2012-06-07 21:39:32 UTC
Permalink
Post by lidia
Any pointers on how I can get anything printed to command line from gradle
appreciated.
Are you trying to print to standard out from a build script? From a Gradle
plugin? From a test? In general, a simple `println` should be enough.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw

--
View this message in context: http://gradle.1045684.n5.nabble.com/Getting-stdout-messages-on-command-line-tp5709858p5709866.html
Sent from the gradle-user mailing list archive at Nabble.com.
lidia
2012-06-07 22:23:11 UTC
Permalink
Hi Peter

I'm trying to write from a java class that's not a test class. It's a
utility class that scans test base for testng annotated tests, in order to
print tests belonging to a specified group. This class is located in
src/testUtil/java as opposed to the tests located in src/test/java. I don't
see any output from the class execution. My build.gradle has the following
entries (among others):

test.testLogging.showStandardStreams = true

// compile for util
configurations{
testUtilCompile.extendsFrom testCompile
}

sourceSets {
testUtil {
java {
srcDir 'src/testUtil/java'
}
}
}

task listTests(type:JavaExec){
main = "testUtil.java.TestGroupScanner"
classpath = sourceSets.testUtil.runtimeClasspath
systemProperty '--testbase', '../../test/java'
if (project.hasProperty("group")){
args group
}
}

No output appears on the command line.


--
View this message in context: http://gradle.1045684.n5.nabble.com/Getting-stdout-messages-on-command-line-tp5709858p5709867.html
Sent from the gradle-user mailing list archive at Nabble.com.
Peter Niederwieser
2012-06-07 22:38:18 UTC
Permalink
I've just tried a similar example based on JavaExec, and `System.out.println`
worked just fine, without any further configuration. Maybe there is a
problem with `TestGroupScanner`? Also make sure to try with a recent Gradle
version. If you need more help on this, please provide a self-contained
example that allows us to reproduce the problem.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw

--
View this message in context: http://gradle.1045684.n5.nabble.com/Getting-stdout-messages-on-command-line-tp5709858p5709868.html
Sent from the gradle-user mailing list archive at Nabble.com.
lidia
2012-06-27 23:50:01 UTC
Permalink
Once I moved my classes to src/test/util I got the stdout messages printed on
the command line.

Lidia

--
View this message in context: http://gradle.1045684.n5.nabble.com/Getting-stdout-messages-on-command-line-tp5709858p5709918.html
Sent from the gradle-user mailing list archive at Nabble.com.

Loading...