简体   繁体   中英

Android Studio(0.2.0) Unit test No output on logcat

When I write a unit test on Android Studio(0.2.0) with some log output, but alfter I ran it, there are no logs except

09-13 11:16:39.747  20963-20978/com.wanshangle I/TestRunner: started: testAndroidTestCaseSetupProperly(com.wanshangle.api.test.AsyncHttpRequestTest)
09-13 11:16:39.747  20963-20978/com.wanshangle I/TestRunner: finished: testAndroidTestCaseSetupProperly(com.wanshangle.api.test.AsyncHttpRequestTest)
09-13 11:16:39.747  20963-20978/com.wanshangle I/TestRunner: passed: testAndroidTestCaseSetupProperly(com.wanshangle.api.test.AsyncHttpRequestTest)

By default when running unit tests in android studio it shows you a runner log window, this only relates to the actual running though. If you wan't to see the log you get from Log.x you have to open the LogCat window. You'll find this under "View->Tool Windows->Android":

Android Studio LogCat视图

In addition to Almund's answer:

If you want that the Android-Monitor stays visible and (and not switching back to the Run-Window) you'll uncheck "activate Tool-Window" in your tests "Run configuration..."

Things have changed in Android Studio since the last answer, but this is still a problem. I haven't figured out how to see regular Log statements, but I have found that System.println() commands can be viewed.

This trick works as of Android Studio Dolphin 2021.3.1 Patch 1 .

Select Run -> Edit Configurations

在此处输入图像描述

Click on Modify Options .

在此处输入图像描述

Make sure that there is a check mark next to Specify logs to be shown in console .

在此处输入图像描述

click OK and you should be good.

NOTE: System.println() messages will now display in the test results log (not the logcat).

Wish I had a better solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM