System.out in tested code is not shown on console or log file


(Rice Yeh) #1

I use println to show output to console and a log file in a Scala TestNG test code. In Maven, the output to the console and the log file is normal . In Gradle, output to console is swallowed and output to the log file only shows WARNING and ERROR messages. Gradle’s document says it redirects anything written to standard output to it’s logging system at the QUIET log level. My question is, since QUIET > WARNING, messages from println should be shown on both the console and log file.


(Rice Yeh) #2

Take the scala sample quickstart provided included in gradle 1.9. There is a test case PersonImplTest and I insert a println(“message supposed to logged at QUIET level”) like below:

// FIXME: use a Scala test framework to run a test
  def testCanCreatePersonImpl(): Unit = {
    def person: Person = new PersonImpl(List("bob", "smith"))
    println("message supposed to logged at QUIET level")
     person
  }

When I run with gradle test, the message is not show. But when I run with gradle -i test, the message is shown. So the code in the test case is not logged at QUIET level but INFO level. Is this a bug?


(Peter Niederwieser) #3

It is not a bug. To see messages printed to standard out/err, use ‘test.testLogging.showStandardStreams()’.