android-showcase icon indicating copy to clipboard operation
android-showcase copied to clipboard

Testing: Add UI Tests

Open igorwojda opened this issue 5 years ago • 5 comments

We could add some UI test to the project (Espresso?)

eg. basic tests like

  • run the app
  • navigate to details of first item
  • navigate to favourites/profile

igorwojda avatar Apr 19 '20 19:04 igorwojda

I would like to pick this one up

sfeatherstone avatar Jun 08 '20 15:06 sfeatherstone

Go for it - just write the tests and I will update pipeline (with Github Actions) to run them on each PR

BTW I was experimenting with Barista and I was really happy with the results - the tests where clean and quite expressive:

    @Test
    fun whenUserEntersNameHeCanJoinTheMeeting() {
        // Given
        launchFragmentInMaterialContainer<IntroFragment>()
        writeTo(R.id.userNameEditText, "Bob")

        // When
        clickOn(R.id.joinMeetingButton)

        // Then
        testNavHostControllerRule.currentDestination?.id shouldBeEqualTo R.id.joinMeetingFragment
    }

    @Test
    fun whenUserJoinsMeetingWithoutEnteringNameDisplayError() {
        // Given
        launchFragmentInMaterialContainer<IntroFragment>()

        // When
        clickOn(R.id.joinMeetingButton)

        //  Then
        assertError(R.id.userNameTextInputLayout, R.string.user_name_is_required)
    }

launchFragmentInMaterialContainer is my helper to run fragments in the material theme without setting it each time (when component requires it tests crashed because default test theme is not material theme):

inline fun <reified F : Fragment> launchFragmentInMaterialContainer(
    fragmentArgs: Bundle? = null,
    @StyleRes themeResId: Int = R.style.Theme_AppTheme,
    factory: FragmentFactory? = null
): FragmentScenario<F> {
    return launchFragmentInContainer<F>(fragmentArgs, themeResId, factory)
}

igorwojda avatar Jun 08 '20 15:06 igorwojda

FYI I have converted project to GitHub Actios - now UI tests will run witch each PR (although there are not good UI tests yet)

igorwojda avatar Jun 13 '20 12:06 igorwojda

This is blocked by issue #109. UI tests will not run in dynamic modules without the upgrade

sfeatherstone avatar Jul 20 '20 20:07 sfeatherstone

Sorry for long hold. #109 is adressed. @sfeatherstone feel free to grad this issue if you are still ager to write some UI tests.

igorwojda avatar Feb 09 '21 00:02 igorwojda