I'm running JUnit4 tests using Flank/Firebase Test Lab against Android API28 devices, and none of my logging messages that I print from my test listener are being printed in the device's catlog.
I tried a few things:
Attempt 1
println("===TEST")
Attempt 2
import android.util.Log
Log.e("UnitTest", "===TEST MESSAGE")
Attempt 3
bundle = Bundle()
bundle.putString(Instrumentation.REPORT_KEY_IDENTIFIER, MyTestListener::class.java.name)
bundle.putString(InstrumentationResultPrinter.REPORT_KEY_NAME_CLASS, description.className)
bundle.putString(InstrumentationResultPrinter.REPORT_KEY_NAME_TEST, description.methodName)
bundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "=== TEST_FINISHED")
InstrumentationRegistry.getInstrumentation().sendStatus(InstrumentationResultPrinter.REPORT_VALUE_RESULT_OK, bundle)
None of those approaches seemed to have included my logs in the catlog
output... yet I can see that my test case ran and passed. Does anyone have any suggestions or know what I'm doing wrong?
When I run this locally with breakpoints, my code is definitely being hit, and messages are being printed to Stdout.
Thank you!
Attempt 2 should actually be the accepted answer:
import android.util.Log
Log.e("UnitTestClassName", "===TEST MESSAGE")
My specific issue was that the test execution path didn't go through these lines of code.