Testing: Add UI Tests
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
I would like to pick this one up
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)
}
FYI I have converted project to GitHub Actios - now UI tests will run witch each PR (although there are not good UI tests yet)
This is blocked by issue #109. UI tests will not run in dynamic modules without the upgrade
Sorry for long hold. #109 is adressed. @sfeatherstone feel free to grad this issue if you are still ager to write some UI tests.