4

I need a quick way to do a few tests and don't want to look at the Dalvik Debug Monitor. I just want to create a quick public static void main() and print some results to experiment with for debugging. I thought I could use the unit testing framework to get some results on the console stdout, but System.out.println() still goes to the log (as well as Log.d()).

So is there a way to print the the stdout when running a unit test?

ant debug install test
test:
 [echo] Running tests ...
 [exec]
 [exec] com.MainTest:.
 [exec] Test results for InstrumentationTestRunner=.
Chloe
  • 25,162
  • 40
  • 190
  • 357
  • Oh yeah, it has to run in Android because the library I'm making use of to test only runs in Android. So... unless there was a way to include android-2.3.jar on the classpath... – Chloe Aug 29 '12 at 03:18
  • FYI, you can click the "edit" link at any time to add those "oh yeah, I forgot about..." thoughts. In fact, this is the preferred method of updating questions here since you can completely edit your question in any way that makes it clearer or adds information needed for us to help answer. – Code-Apprentice Aug 29 '12 at 04:31
  • 1
    p.s. Unfortunately, I can't answer your question as I'm just starting to learn Android programming myself. Welcome to stackoverflow and good luck with your programming! – Code-Apprentice Aug 29 '12 at 04:32
  • Did you finally manage to find a solution to this problem? – Andrea Nov 05 '12 at 22:26
  • @Andrea Sorry no I didn't. I am forced to look at Debug Monitor ddms.bat. – Chloe Nov 15 '12 at 21:26

1 Answers1

1

I didn't find the option to enable stdout redirection for a unit test, but here is a workaround. After running a unit test (or in a separate shell window) type:

adb logcat|grep System.out

On Windows, it should probably be adb logcat | FINDSTR System.out

It will only display System.out statements including the output of the unit test.

ejboy
  • 4,081
  • 5
  • 30
  • 32