By default, Logcat output (from Log calls) doesn't seem to go anywhere when running tests under Robolectric. To see it, the log stream has to be set:
ShadowLog.stream = System.out;
However, there might be undesired spurious output from Android or third-party components. One way to deal with this would be to set the stream to a custom one that filters the output in some way before writing it to standard out. Alternatively, you could provide a custom ShadowLog implementation that filters by tag or call stack. One of my projects checks to see if the current thread's stack trace has a class in the app's package right before Log. To avoid unnecessary checks, the result on whether the log is "internal" is cached by tag.
No comments:
Post a Comment