Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the output of System.out.println go in gradle test?

Tags:

gradle

Where does the output of System.out.println go in gradle test?

I have a sample test defined as follows:

import org.junit.Test; import static org.junit.Assert.*;      public class LibraryTest {         @Test public void NaiveScenarioTest() {           System.out.println("java sample scenario started");           SampleScenario s = new SampleScenario("sample");         }     } 

Running gradle test, I get all the success indicators, but the stdout output of the println doesn't show in the terminal nor in gradle's html report. Whereas this is desired only for a quick debug scenario, I still would be happier to have stdout redirected somewhere visible, preferably showing in the terminal as I gradle test.

What is the simplest or best advice?

like image 530
matanster Avatar asked Apr 08 '17 02:04

matanster


People also ask

Where is the output of Gradle build?

By default, gradle outputs generated source files into build/classes directory.

Where can I find Gradle logs?

Gradle does not redirect its logs in a separate file in Android Studio. Therefore if you want to view them in a file, you need to build gradle using a command in the terminal and redirect gradle input to a file. This command will redirect all standard output and error messages from gradle build to a file called myLogs.

How do I create a test report in Gradle?

How to generate a Test Report. Gradle generates a Test Report automatically when it runs the entire Test Suite. To do the same, run ./gradlew test (or gradlew. bat test from Windows), or run the test Gradle task from your IDE.


1 Answers

The test output is part of the standard html report located in build/reports/tests/test/index.html. Simply click through the report to find the specific test you are interested in and there is a tab with Standard Output (and Standard Error if applicable).

To show the outputs during the gradle test run, you can modify your test task:

test {     testLogging {         showStandardStreams = true     } } 

You can customize the output even more, see the docs.

like image 108
MartinTeeVarga Avatar answered Sep 22 '22 18:09

MartinTeeVarga