Where is the output from an android instrumented test?

Ray Tayek picture Ray Tayek · Dec 13, 2015 · Viewed 7.7k times · Source

I managed to get gradle cC to work. My test just prints out and logs one line of text.

grep -r text * fails.

where is the system.out and logging output?

thanks

edit: i found the output for the unit tests (it's in .../app/build/test-results/). but still no luck with the other.

is there a way to save the output from the instrumented tests somehow?

Answer

David Medenjak picture David Medenjak · Jan 27, 2016

Running gradlew connectedCheck will generate test results in the build directory, see

\build\reports\androidTests\connected\
  and
\build\outputs\androidTest-results\connected\

These instrumentation tests will also log their output in LogCat, along with any Log.d statements. Using System.out.print in your test cases will result in an output like this:

01-27 18:05:30.445 32664-32677/your.packagename I/System.out﹕ Test output

If you need to also persist the output you could probably write a gradle task running adb logcat and pulling the logs from the device.