我们在SDK上使用Robolectric
用于单元测试,但有一点我注意到,当我们运行测试时,这绝对会使日志变得混乱(这在Jenkins
上尤其是一个问题,当你进行近200次测试时。)
我们所有测试开始的一个例子是,
@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();
}
}
但是当我们跑过这条线时,
activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().visible().get();
我们在日志中得到了这个,
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.
三条线,一遍又一遍,一遍又一遍。打印输出深入Android
来源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;
}
因此,如果没有找到如何压制记录器(我真的 ),我很乐意找到一种不会在每次开始时被击中的方法测试