gpt4 book ai didi

android - 由于 App not Idle 异常 : The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED,Espresso 测试失败

转载 作者:行者123 更新时间:2023-12-05 05:17:43 25 4
gpt4 key购买 nike

我的 Espresso 测试在 Espresso 版本 2.2.2 上运行良好,但是当我将我的工作室更新到最新版本并应用迁移规则时,测试将失败并需要更新版本。
库使用

androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.1'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestImplementation "com.android.support:support-annotations:${support}"
implementation fileTree(include: ['*.jar'], dir: 'libs')

对于测试期间的空闲资源,我使用 IdlingResourceSample我也试过idling-resource-intent-service因为我正在使用 IntentServiceBroadcastReceiver
因为 Espresso 有问题 Espresso.onIdle & Espresso IdlingResourceRegistry.sync已经报告并将在下一个版本中修复。我使用 IdlingRegistry 进行注册。但我仍然得到 AppNotIdleException
日志猫

android.support.test.espresso.AppNotIdleException: Looped for 35 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED.
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:90)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.check(ViewInteraction.java:291)
at com.company.project.InstrumentedDeepLinkTest.setDeepLinkUri(InstrumentedDeepLinkTest.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)

我已经从 developer Options 中禁用了动画

在分析了哪个 AsyncTask 让我的 App 忙碌之后,我得到了 thread pool 有很多 AsyncTask 相关到 sun.misc.Unsafe.park(Unsafe.java:299)
线程池

AsyncTask #9: WAITING
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.lang.Object.wait(Native Method)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.lang.Thread.parkFor$(Thread.java:1220)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: sun.misc.Unsafe.park(Unsafe.java:299)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1036)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
02-21 16:16:39.955 1611-1670/com.myCompany.MyProject W/System.err: java.lang.Thread.run(Thread.java:818)

最佳答案

在此 Google Group thread 上找到了解决方案

我有一个正在淡出的进度条,但没有将可见性设置为 GONE,所以它不断更新 ui。因此,尽管后台工作已完成并且空闲资源已设置为空闲,但应用程序永远不会空闲。

关于android - 由于 App not Idle 异常 : The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED,Espresso 测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48887518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com