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 #3607: ExplorationPlayer End to End tests #3608

Merged
merged 72 commits into from
Aug 21, 2021

Conversation

FareesHussain
Copy link
Contributor

@FareesHussain FareesHussain commented Jul 29, 2021

Explanation

Fixes #3607

This pr introduces e2e tests in ExplorationPlayerTests using Ui Automator

How to run UI Automator tests

Prerequisites:

  1. To be able to build oppia using bazel
    bazel build oppia
    
  2. Add adb to the environment (platform-tools) i.e, add the following line to the .bashrc or the file path according to the Operating System.
    export PATH=/home/<username>/Android/Sdk/platform-tools:$PATH
    
  3. download and install test-services-1.1.0.apk and orchestrator-1.1.0 in the emulator. (run command in the directory where both apk are downloaded)
    adb install -r test-services-1.1.0.apk && adb install -r orchestrator-1.1.0.apk
    
  4. java version 8 (Optional, only for uiautomatorviewer)
    java -version
    
    output:
    openjdk version "1.8.0_292"
    OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~18.04-b10)
    OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

Steps to run the tests:

  1. Build the BaseTest android_binary from the instrumentation module
    bazel build :oppia_test && bazel build //instrumentation:ExplorationPlayerTest
    
  2. install the oppia_test.apk and the ExplorationPlayerTest.apk
    adb install -r bazel-bin/oppia_test.apk && adb install -r bazel-bin/instrumentation/ExplorationPlayerTest.apk
    
  3. Run the instrumentation tests using am instrument command
adb shell 'CLASSPATH=$(pm path androidx.test.services) app_process / \
androidx.test.services.shellexecutor.ShellMain am instrument -w -e clearPackageData true \
-e targetInstrumentation org.oppia.android.app.instrumentation/androidx.test.runner.AndroidJUnitRunner \
androidx.test.orchestrator/.AndroidTestOrchestrator'

image

Using.android.test.orchestrator.mp4

Ran using single testcase for both with argument and without argument

Failing.test.case.included.mp4

Ran using duplicate testcase for both without argument and with argument

Using.duplicate.test.case.2.2.pr.mp4

Note: There are few flacky tests which is obvious for E2E tests but each test passes on individual run.

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

@anandwana001
Copy link
Contributor

Assigning to @FareesHussain as well, to keep track of adding screenshots.

@FareesHussain
Copy link
Contributor Author

Assigning to @FareesHussain as well, to keep track of adding screenshots.

Adding screenshots might take a time here as the whole test suite has 188 testcases, it might almost take more than 2 hrs

@Sparsh1212 Sparsh1212 added the PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged label Jul 30, 2021
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @FareesHussain. Left one comment, but in general I think that:

  1. We need to leverage helpers to simplify the tests (per a comment I added in one of the base PRs)
  2. The tests we add for UiAutomator should be higher-level and cover general user flows rather than testing at the same level of specificity of Robolectric. Please follow up with me & Akshay if you're unsure how to proceed, but I did add one example to my comment. PTAL.

@BenHenning BenHenning removed their assignment Jul 30, 2021
… setup-uiautomator

� Conflicts:
�	third_party/maven_install.json
…oppia-android into exploration-e2e-tests

� Conflicts:
�	instrumentation/src/javatest/org/oppia/android/instrumentation/ExplorationPlayerTest.kt
val imageSelectionView = device.findObjectByRes("interaction_container_frame_layout")
device.waitForRes("image_click_interaction_image_view")
imageSelectionView!!.children!!.get(2)!!.click()
device.findObjectByText("SUBMIT")!!.click()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'm using !!. instead of ?.
So that in case the view doesn't exist the test fails immediately, else the test runs as normal till it reaches the assertion and then gives a failure which might be confusing

Copy link
Member

Choose a reason for hiding this comment

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

I suggest returning only non-nullable types from your helper class and utilize checkNotNull with clearer error messages if an object isn't found. That'll give you the quick-failure you're looking for with clearer context, and doesn't even give the choice to test authors to potentially avoid the null-check (since we do want things to be really crisp).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -116,6 +116,7 @@ class ClickableAreasImage(
newView.isFocusable = true
newView.isFocusableInTouchMode = true
newView.tag = clickableArea.label
newView.contentDescription = clickableArea.label
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aggarwalpulkit596 PTAL

This enables content description for each image region in ImageRegionSelectionInteraction
image

Copy link
Member

Choose a reason for hiding this comment

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

This isn't correct. The label will give away the answer, so we introduced another property for content descriptions in image region.

However, looking at https://github.com/oppia/oppia/blob/develop/extensions/interactions/ImageClickInput/ImageClickInput.py it seems we never did add this. Per oppia/oppia#9924 I guess we didn't finish this which introduces a problem. We unfortunately won't be able to use this method.

Can you file an issue to add support for oppia/oppia#9924 once it's ready & add that as a TODO here to fix the reference? We probably aren't going to be able to do better than the direct indexing without content description support.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done
#3712

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.

Approved for code owner file.

@oppiabot oppiabot bot unassigned rt4914 Aug 20, 2021
@oppiabot
Copy link

oppiabot bot commented Aug 20, 2021

Unassigning @rt4914 since they have already approved the PR.

Copy link
Contributor

@aggarwalpulkit596 aggarwalpulkit596 left a comment

Choose a reason for hiding this comment

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

LGTM

@oppiabot
Copy link

oppiabot bot commented Aug 20, 2021

Unassigning @aggarwalpulkit596 since they have already approved the PR.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @FareesHussain. Couple more comments, but this looks pretty close to LGTM. Once you address these I'll take on more full pass (check open conversation threads; I didn't submit the review correctly this time).

@BenHenning
Copy link
Member

Also @rt4914 PTAL at the comment I replied to above re: the content description.

@BenHenning BenHenning assigned rt4914 and FareesHussain and unassigned BenHenning Aug 20, 2021
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @FareesHussain. This LGTM!

app/src/main/res/layout-land/story_chapter_view.xml Outdated Show resolved Hide resolved
@BenHenning
Copy link
Member

Since no reviewer threads are open & everyone's approved, merging this.

@BenHenning BenHenning merged commit 206f92f into oppia:develop Aug 21, 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.

Write e2e tests for explorationplayer
6 participants