how to print logs in cmd console while execute android instrument test how to print logs in cmd console while execute android instrument test android android

how to print logs in cmd console while execute android instrument test


I guess @MoMo did something like this to have logging output in command prompt window:

In your test class define a function:

private void out(String str) {    Bundle b = new Bundle();    b.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "\n" + str);    InstrumentationRegistry.getInstrumentation().sendStatus(0, b);}

Then simply use it in @Test functions like:

out("Some message...");

The output appears when running the test in Command Prompt window with adb shell am instrument..., but it is not shown in Run window of Android Studio. It somehow filters the output of test runs, and I cannot find a setting to modify this filter.