其他分享
首页 > 其他分享> > android – Espresso测试错误:AppNotIdleException

android – Espresso测试错误:AppNotIdleException

作者:互联网

我关闭了开发者选项的所有动画.
但是当我尝试点击其中一个按钮时,我仍然会遇到此异常.

我的应用程序确实是活跃的,并没有完全闲置,但我无法改变它.

android.support.test.espresso.AppNotIdleException: Looped for 6930
iterations over 60 SECONDS. The following Idle Conditions failed .
 at dalvik.system.VMStack.getThreadStackTrace(Native Method)
 at java.lang.Thread.getStackTrace(Thread.java:580)
 at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
 at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
 at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
 at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
 at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)

解决方法:

过去几天我一直在努力解决这个问题.
这是我用来识别“违规者”的方法:

private void dumpThreads() {
    int activeCount = Thread.activeCount();
    Thread[] threads = new Thread[activeCount];
    Thread.enumerate(threads);
    for (Thread thread : threads) {
        System.err.println(thread.getName() + ": " + thread.getState());
        for (StackTraceElement stackTraceElement : thread.getStackTrace()) {
            System.err.println("\t" + stackTraceElement);
        }
    }
}

就我而言,Facebook SDK使用的是AsyncTask线程池.

标签:ui-testing,android,android-espresso
来源: https://codeday.me/bug/20190929/1832433.html