如何编写测试以检查视图可见性是否在 Robolectric 中消失?

How can I write a test where I check if the view visibility is gone in Robolectric?

在Robolectric中,如果我想检查视图是否可见,我可以执行以下操作 onView(Matchers.allOf(withId(R.id.btn_action))).check(matches(isDisplayed())) 想知道如果视图可见性消失了怎么办,我如何在测试中检查它?

你试过了吗:

onView(Matchers.allOf(withId(R.id.btn_action))).check(matches(not(isDisplayed())))

onView(Matchers.allOf(withId(R.id.btn_action))).check(doesNotExist())