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?
By default, gradle outputs generated source files into build/classes directory.
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 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With