Reputation: 537
My Espresso test is working fine with Espresso version 2.2.2
but When I update my studio to latest one and applied migration rule test going to fail and required to update the version.
library using
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')
For Idling resource during testing I am using the IdlingResourceSample also I also tried idling-resource-intent-service As I am using IntentService
and BroadcastReceiver
.
As There is issue in Espresso
Espresso.onIdle & Espresso IdlingResourceRegistry.sync which is already reported and will fix in next release. I use IdlingRegistry
for registering. but still I am getting AppNotIdleException
Log Cat
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)
I disabled already animations from developer Options
After Analyzing which AsyncTask
is keeping my App
busy, I got the thread pool
having many AsyncTask
related to sun.misc.Unsafe.park(Unsafe.java:299)
.
Thread Pool
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)
Upvotes: 3
Views: 4686
Reputation: 10497
Found the solution on this Google Group thread
I had a progress bar that was fading out, but not setting visibility to GONE
, so it kept updating the ui. So the app never goes to idle despite, the background work is done and the idling resource is set to free.
Upvotes: 2