[英]How do I print the stdout for unit test in Android?
I need a quick way to do a few tests and don't want to look at the Dalvik Debug Monitor. 我需要一种快速的方法来进行一些测试,并且不想看Dalvik Debug Monitor。 I just want to create a quick public static void main()
and print some results to experiment with for debugging. 我只想创建一个快速的public static void main()
并打印一些结果以进行调试。 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()
). 我以为我可以使用单元测试框架在控制台stdout上获得一些结果,但是System.out.println()
仍然进入日志(以及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=.
I didn't find the option to enable stdout redirection for a unit test, but here is a workaround. 我没有找到为单元测试启用stdout重定向的选项,但这是一种解决方法。 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
在Windows上,它可能应该是adb logcat | FINDSTR System.out
adb logcat | FINDSTR System.out
It will only display System.out statements including the output of the unit test. 它将仅显示System.out语句,包括单元测试的输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.