我直接从this snippet带走了Robolectric's own unit tests:
Handler handler = new Handler();
Messenger messenger = new Messenger(new Messenger(handler).getBinder());
运行(使用./gradlew test
)时,出现空指针异常:
com.test.robono.RoboTest > testBinder FAILED
java.lang.NullPointerException
at android.os.Messenger.getBinder(Messenger.java:67)
at com.test.robono.RoboTest.testBinder(RoboTest.java:16)
这必须在Robolectric仓库内工作,为什么它在我的仓库中失败了?