我有几个非常简单的测试只是为了尝试 Espresso:
@Test(timeout = 3000)
public void testSomeButton()
{
Espresso.onView(ViewMatchers.withId(R.id.someid)).perform(ViewActions.click());
Matcher<Intent> intentMatcher = IntentMatchers.hasComponent(SomeActivity.class.getName());
Intents.intended(intentMatcher);
}
问题是,Espresso 有时会在测试时卡住。 Android Studio 中的黄色 Spinner 一直在旋转,我可以看到我的 Android 设备上的屏幕只是默认的 android 主屏幕,这意味着 Activity 尚未启动。我的测试也有一些超时,所以我猜这意味着测试还没有开始。
如果有帮助: - 在一个类(class)中有 10 个类似的测试(针对不同的 Activity )。 - 有时在几次成功的测试后,它会在第 6 个测试时卡住(例如),有时它会运行所有这些测试
最佳答案
您可能会在某些屏幕上运行一些动画。把它关掉。它不会卡住。
关于android - Espresso 在某些测试中随机卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38133349/