We're using Robolectric for UnitTests on our SDK, but there's one thing I've noticed which is absolutely cluttering up the logs when we run our test (this is especially an issue on Jenkins, when you're running nearly 200 tests).
An example of the start of all our tests is,
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, emulateSdk=21)
public class AppTest {
private MainActivity activity;
@Before
public void setUp() throws Exception {
activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().visible().get();
}
}
But when we run over the line,
activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().visible().get();
We get this in our logs,
18:56:02 W/InputEventReceiver: Attempted to consume batched input events but the input event receiver has already been disposed.
18:56:02 W/InputEventReceiver: Attempted to consume batched input events but the input event receiver has already been disposed.
18:56:02 W/InputEventReceiver: Attempted to consume batched input events but the input event receiver has already been disposed.
Three lines, over and over, and over again. The printout happens deep within the Android source, in android.view.InputEventReceiver:consumeBatchedInputEvents,
public final boolean consumeBatchedInputEvents(long frameTimeNanos) {
if (mReceiverPtr == 0) {
Log.w(TAG, "Attempted to consume batched input events but the input event "
+ "receiver has already been disposed.");
} else {
return nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos);
}
return false;
}
So without finding out how to suppress the logger (which I'd really prefer not to do), I'd love to find a way for this not to be hit at the beginning of every test.