Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does LogCat's Log.x() output go when running Android JUnit tests?

Tags:

I noticed that when testing plain Java classes via test classes derived from TestCase and AndroidTestCase, LogCat output disappears.

Is it possible to still capture the output of these messages? or my only recourse is to use the much more sluggish ActivityInstrumentationTestCase2<> as a base class?

like image 258
uTubeFan Avatar asked May 12 '11 18:05

uTubeFan


2 Answers

I had similar issue... The point here is that the logcat view available in Eclipse does not show anything when running the project in Android Junit mode. At least, in the Android 2.1 that I was using, that's the behavior.

You can workaround this issue by checking the logcat from command line (terminal window):

# check the device name you are using
# It gives something like this:
$ ./adb devices
List of devices attached 
emulator-5554   device

# open logcat of the device
$ ./adb -s emulator-5554 logcat
D/AndroidRuntime(  943): 
D/AndroidRuntime(  943): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(  943): CheckJNI is ON
.
.
.
like image 124
bruno.braga Avatar answered Sep 22 '22 14:09

bruno.braga


Both of these statements produce log in logcat:

    android.util.Log.d(TAG, "This is Log.d");
    System.out.println("This is System.out.println");
like image 33
Diego Torres Milano Avatar answered Sep 25 '22 14:09

Diego Torres Milano