How to print messages on console in Junit for Android?

443 views
Skip to first unread message

puppuppy

unread,
Feb 7, 2014, 3:27:42 AM2/7/14
to android-...@googlegroups.com
Now I am developing test cases in Android using Junit, and use am command to test. However, when I want to print some important messages on console other than in logcat during test, I find it's impossible, the messages will always be shown in logcat file because Android redirect the standard output to logcat. I think there must exist a solution because I see Junit will show some messages on console itself during test, for example, some info when assert fails, just like:

com.marvell.capricorn.functional.AcmSinglePathOperationTest: Failure in testAcmSinglePath: junit.framework.ComparisonFailure: expected: but was: at com.marvell.capricorn.functional.AcmSinglePathOperationTest.singlePathExecAll(AcmSinglePathOperationTest.java:117) at com.marvell.capricorn.functional.AcmSinglePathOperationTest.testAcmSinglePath(AcmSinglePathOperationTest.java:179) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Test results for AcmPathTestRunner=.F Time: 14.28
FAILURES!!! Tests run: 1, Failures: 1, Errors: 0


So, is there any method to print message on console? THX!

Reply all
Reply to author
Forward
0 new messages