Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3413: Fix espresso test failing in topic practice fragment test #3743

Conversation

yash10019coder
Copy link
Contributor

@yash10019coder yash10019coder commented Aug 28, 2021

Explanation

Fixes #3413
unregistered the idling resource for the specific test as it was not need it was creating IdlingResouceTImedOutException

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

For UI-specific PRs only

If your PR includes UI-related changes, then:

  • Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes
  • For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see RTL guide)
  • Add a video showing the full UX flow with a screen reader enabled (see accessibility guide)
  • Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing

…_selectSubtopics_clickStartButton_skillListTransferSuccessfully by unregistering the idling resouce in it
@rt4914
Copy link
Contributor

rt4914 commented Aug 30, 2021

@anandwana001 Can you please check this first if the solution is correct or not?

@anandwana001
Copy link
Contributor

This does seem like a fix due to the idling resource thing, but we need to figure out why this is happening here only and not in any other test case.

@anandwana001
Copy link
Contributor

@yash10019coder Could you come up with some details that why the error is happening?
Also, in this PR we have to check other UI tests as well just in case if we are facing a similar issue at another tests or not.

@yash10019coder
Copy link
Contributor Author

@anandwana001 this error is happening due to the idling resources it times out and then tests fails and it is not being able to execute the intent check lines and in other test cases intent check is not happening

@anandwana001
Copy link
Contributor

@yash10019coder Is it specific to this test file only? What about the other test files, where we are doing the intent test?

@anandwana001 anandwana001 removed their assignment Sep 3, 2021
@yash10019coder
Copy link
Contributor Author

@anandwana001 I haven't checked for others but I'm pretty sure for this

@yash10019coder
Copy link
Contributor Author

@anandwana001 I have seen other tests which are checking intent some of them are using testCoroutineDispather.runCurrent() some of them are not using it or maybe using internally all of those test cases passes successfully I have also tried using it but it is not working test is failing and I have also wrapped it inside .use after launching the activity

@yash10019coder
Copy link
Contributor Author

@anandwana001 I ahve tried many things only unregistering the idling resources works every other way it fails made a commit PTAL

@oppiabot oppiabot bot assigned anandwana001 and unassigned yash10019coder Sep 3, 2021
@oppiabot
Copy link

oppiabot bot commented Sep 3, 2021

Unassigning @yash10019coder since a re-review was requested. @yash10019coder, please make sure you have addressed all review comments. Thanks!

@anandwana001
Copy link
Contributor

@yash10019coder Could you add a screenshot of your local espresso and robolectric test result. On Actions this test is failing with the below error log.

org.oppia.android.app.topic.practice.TopicPracticeFragmentTest > testTopicPracticeFragment_loadFragment_selectSubtopics_clickStartButton_skillListTransferSuccessfully FAILED
    java.lang.NullPointerException
        at org.oppia.android.app.recyclerview.RecyclerViewMatcher$Companion$atPositionOnView$1.matchesSafely(RecyclerViewMatcher.kt:53)
        at org.oppia.android.app.recyclerview.RecyclerViewMatcher$Companion$atPositionOnView$1.matchesSafely(RecyclerViewMatcher.kt:29)
        at org.hamcrest.TypeSafeMatcher.matches(TypeSafeMatcher.java:65)
        at androidx.test.espresso.base.ViewFinderImpl$MatcherPredicateAdapter.apply(ViewFinderImpl.java:130)
        at androidx.test.espresso.core.internal.deps.guava.collect.Iterators$5.computeNext(Iterators.java:637)
        at androidx.test.espresso.core.internal.deps.guava.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141)
        at androidx.test.espresso.core.internal.deps.guava.collect.AbstractIterator.hasNext(AbstractIterator.java:136)
        at androidx.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:69)
        at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:223)
        at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:65)
        at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:158)
        at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:155)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at android.os.Handler.$$robo$$android_os_Handler$handleCallback(Handler.java:873)
        at android.os.Handler.handleCallback(Handler.java)
        at android.os.Handler.$$robo$$android_os_Handler$dispatchMessage(Handler.java:99)
        at android.os.Handler.dispatchMessage(Handler.java)
        at org.robolectric.shadows.ShadowPausedLooper$IdlingRunnable.run(ShadowPausedLooper.java:305)
        at org.robolectric.shadows.ShadowPausedLooper.executeOnLooper(ShadowPausedLooper.java:270)
        at org.robolectric.shadows.ShadowPausedLooper.idle(ShadowPausedLooper.java:87)
        at org.robolectric.android.internal.LocalControlledLooper.drainMainThreadUntilIdle(LocalControlledLooper.java:15)
        at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:318)
        at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:178)
        at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:119)
        at org.oppia.android.app.topic.practice.TopicPracticeFragmentTest.testTopicPracticeFragment_loadFragment_selectSubtopics_clickStartButton_skillListTransferSuccessfully(TopicPracticeFragmentTest.kt:263)

@yash10019coder
Copy link
Contributor Author

yash10019coder commented Sep 7, 2021

androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 539, 1408 and precision: 16, 16' on view 'with id: org.oppia.android:id/topic_practice_skill_list'.
at androidx.test.espresso.PerformException$Builder.build(PerformException.java:86)
at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:87)
at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:59)
at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:322)
at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:178)
at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:119)
at org.oppia.android.app.topic.practice.TopicPracticeFragmentTest.testTopicPracticeFragment_loadFragment_selectSubtopics_clickStartButton_skillListTransferSuccessfully(TopicPracticeFragmentTest.kt:278)
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 androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at androidx.test.internal.runner.junit4.statement.RunAfters.evaluate(RunAfters.java:61)
at org.oppia.android.testing.AccessibilityTestRule$apply$1.evaluate(AccessibilityTestRule.kt:43)
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 androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
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 androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)
Caused by: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [TestCoroutineDispatcherIdlingResource] to become idle timed out
at androidx.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:61)
at androidx.test.espresso.base.UiControllerImpl$5.resourcesHaveTimedOut(UiControllerImpl.java:434)
at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleTimeout(IdlingResourceRegistry.java:481)
at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleMessage(IdlingResourceRegistry.java:414)
at android.os.Handler.dispatchMessage(Handler.java:102)
at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:148)
at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:525)
at androidx.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:447)
at androidx.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:252)
at androidx.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:162)
at androidx.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:139)
at androidx.test.espresso.action.Tap.sendSingleTap(Tap.java:170)
at androidx.test.espresso.action.Tap.access$100(Tap.java:31)
at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:47)
at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:137)
at androidx.test.espresso.action.ViewActions$1.perform(ViewActions.java:132)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:366)
at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:255)
at androidx.test.espresso.ViewInteraction.access$100(ViewInteraction.java:65)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:158)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:155)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@anandwana001

@anandwana001
Copy link
Contributor

Yes, that's the error from the issue we need to fix in this PR.

@yash10019coder
Copy link
Contributor Author

@an

Yes, that's the error from the issue we need to fix in this PR.

it fixes when we unregister idling resources

@anandwana001
Copy link
Contributor

So, is the current code updated in the PR works or are there any changes coming up?
The current code in the PR doesn't work for me, that test failed. Could you update the PR and let's check if it passes on espresso and robolectric both.

@yash10019coder
Copy link
Contributor Author

Sure

@yash10019coder
Copy link
Contributor Author

Made a commit @anandwana001

@yash10019coder
Copy link
Contributor Author

image

@anandwana001
Copy link
Contributor

Also, could you add a screenshot showing that it is passing for you locally?

@yash10019coder
Copy link
Contributor Author

Also, could you add a screenshot showing that it is passing for you locally?

Actually I ran It locally just now and it is the screenshot of that

@yash10019coder
Copy link
Contributor Author

image

@anandwana001
Copy link
Contributor

Waiting for GitHub actions result.

@yash10019coder
Copy link
Contributor Author

@anandwana001 All checks passed successfully

Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks @yash10019coder
nice finding and fixing 🎉

@anandwana001 anandwana001 assigned rt4914 and unassigned yash10019coder Sep 7, 2021
@yash10019coder
Copy link
Contributor Author

Thanks @anandwana001 can we merge it now?

@anandwana001
Copy link
Contributor

@rt4914 is the code owner and his approval is important here.

Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @yash10019coder

@rt4914 rt4914 merged commit 3dc0a61 into oppia:develop Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Espresso Test failing in TopicPracticeFragmentTest
3 participants