Just use Log.d
.
@RunWith(AndroidJUnit4::class)class LogTest { companion object { private const val TAG = "LogTest" } @Test fun logOutput() { Log.d(TAG, "Hello") }}
Sometimes the Logcat tab is now showing any output, you could try one or more of the following.
- Make sure Logcat tab is selected/active when running the test
Edit Configuration
of theLogTest
: UnderMiscellaneous
checkLogcat -> Clear log before launch
and maybe uncheckInstallation Options -> Skip Installation if APK has not changed
(you can check it again later after logcat is working)- Unplugged the USB cable and plug in again
NOTE: During Instrumented Unit Test run, the package name dropdown in Logcat
tab is usually shown as [DEAD]
, but the log will show despite the [DEAD]
status.
NOTE: System.out.println
used to work in earlier version to print output in the Run
tab, but this is no longer the case with Android Studio 3.5