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

Espresso tests for survey toolbar #179

Merged

Conversation

Chinex-Boroja
Copy link

This is a PR for issue 483, and the PR contains the following:

Overview

The Survey App toolbar was recently revised and updated, so there are needs to write tests to ensure the App is behaving as expected

The Survey App's functionality tested

  • testToolbarLogoNavigation()
  • testSyncMenuItem()
  • testSettingsMenuItem()

Screenshot of passed Tests on Android Studio

IntegrationTests

@wbrunette wbrunette self-requested a review April 2, 2024 13:53
Copy link
Member

@wbrunette wbrunette left a comment

Choose a reason for hiding this comment

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

The tests do not pass on the build server (CircleCI).

org.opendatakit.survey.logic.TestMainMenuActivity > testSettingsMenuItem[avd(AVD) - 11] FAILED
androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: view.getId() is <2131361857/org.opendatakit.survey:id/action_settings>

org.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem[avd(AVD) - 11] FAILED
androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: view.getId() is <2131361858/org.opendatakit.survey:id/action_sync>

@wbrunette
Copy link
Member

Some of these fixes have now been made. Make sure to merge changes back to your update-jdk11 branch. Check out a similar PR that was merged yesterday that had similar issues.

#178

@Chinex-Boroja
Copy link
Author

Some of these fixes have now been made. Make sure to merge changes back to your update-jdk11 branch. Check out a similar PR that was merged yesterday that had similar issues.

#178

Alright @wbrunette, will do that

@Chinex-Boroja
Copy link
Author

Hi @wbrunette tho I merged changes back to my upgrade-jdk11 branch, when I tried following a similar approach from @Stryker101 on this 178 merged PR on my branch, it still keeps failing on CircleCI, I annotated two other tests with @ignore annotations, but still failing with the error messages: org.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem[avd(AVD) - 11] FAILED androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: view.getId() is <2131361858/org.opendatakit.survey:id/action_sync>

@wbrunette
Copy link
Member

You should remove the @ignores from the other test and add @ignore to rg.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem[avd(AVD) as sync requires Services to be installed.

@Stryker101
Copy link

You should remove the @ignores from the other test and add @ignore to rg.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem[avd(AVD) as sync requires Services to be installed.

I was curious about this as well. In my PR the test for sync passed without Services being installed. I looked at the implementation and saw that the handling of the intents were both in a try catch block, but they errors were handled differently. Could this be why Sync test passed without Services?

@Chinex-Boroja
Copy link
Author

You should remove the @ignores from the other test and add @ignore to rg.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem[avd(AVD) as sync requires Services to be installed.

okay, will try that out in a minute

@Chinex-Boroja
Copy link
Author

@wbrunette I added the @ignore annotation org.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem and org.opendatakit.survey.logic.TestMainMenuActivity > testSettingsMenuItem to get the test passing. I think sync and settings require Services to be installed. But I am also wondering why sync test passed on @Stryker101 PR, which he already asked why. Does it have something to do with the try and catch blog?

@Chinex-Boroja
Copy link
Author

@wbrunette I added the @ignore annotation org.opendatakit.survey.logic.TestMainMenuActivity > testSyncMenuItem and org.opendatakit.survey.logic.TestMainMenuActivity > testSettingsMenuItem to get the test passing. I think sync and settings require Services to be installed. But I am also wondering why sync test passed on @Stryker101 PR, which he already asked why. Does it have something to do with the try and catch blog?

Hi @wbrunette Still yet to get a response on this question

@wbrunette
Copy link
Member

I guess I am confused by the question. Looking at @Stryker101 at his test I do not see a sync test.
https://github.com/odk-x/survey/blob/upgrade-jdk11/survey_app/src/androidTest/java/org/opendatakit/survey/activities/MainMenuActivityTest.java

Your statement "I think sync and settings require Services to be installed. " is correct.

@Chinex-Boroja
Copy link
Author

@wbrunette
Copy link
Member

wbrunette commented Jun 3, 2024

Intending is actually a Mock that checks the intent is formed correctly:
https://developer.android.com/training/testing/espresso/intents#validation

So it does not need Services installed

@Chinex-Boroja
Copy link
Author

Intending is actually a Mock that checks the intent is formed correctly: https://developer.android.com/training/testing/espresso/intents#validation

So it does not need Services installed

Okay, thanks for the clarification. Will check that out

@wbrunette wbrunette merged commit 49da0a7 into odk-x:upgrade-jdk11 Jun 5, 2024
3 checks passed
r0ssing pushed a commit to lemurdk/survey that referenced this pull request Jun 16, 2024
* created tests for the main menu activities

* removed unused imports

* included test options in build.gradle

* remove unwanted files

* added test options in build

* ignore annotation added till service pipeline is fixed

* modified method

* clean up and removed unused imports

* ignored test

* added edge cases

* added idling resource

* refactored annotations

* added @ignore annotation
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.

3 participants