Android Test Case - how to view output?

前端 未结 6 915
野趣味
野趣味 2021-01-07 16:05

I\'m using AndroidTestCase for unit testing. I have a unit test which is failing, but I haven\'t figured out how to display output from it. For example, I don\'

相关标签:
6条回答
  • 2021-01-07 16:29

    Go to Debug --> Logcat. Make sure the LogLevel and Filter are correct as well.

    See the screenshot from Android Studio 1.1.0

    From Android Studio 1.1.0

    0 讨论(0)
  • 2021-01-07 16:30

    You shoud see the Log.d() messages in logcat unless your test is crashing much before (i.e in the constructor).

    0 讨论(0)
  • 2021-01-07 16:37

    In my case ,

    System.out.println("Test") is working for JUnits tests,

    Log.d("tag" , "Test") is working for AndroidJUnit tests(Instrumented)

    0 讨论(0)
  • 2021-01-07 16:38

    With Android Studio 2.3.1, works using the old fashioned Java styled

    System.out.println("Start Test");
    

    Here you can see the output:

    0 讨论(0)
  • 2021-01-07 16:40

    You probably disconnected the device/emulator and reconnected. You have to click on the device name again in the list in the Dalvik Debug Monitor for it to reload the logs and keep updating the output.

    0 讨论(0)
  • 2021-01-07 16:43

    Just to be clear, if you're running an emulator you have to use adb logcat.

    Also, make sure you're using the standard android.util.Log.d() to send your output.

    0 讨论(0)
提交回复
热议问题