Skip to content

Instantly share code, notes, and snippets.

@remcomokveld
Created April 14, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remcomokveld/475d14e91b2be5bd34857ad4ff9437c0 to your computer and use it in GitHub Desktop.
Save remcomokveld/475d14e91b2be5bd34857ad4ff9437c0 to your computer and use it in GitHub Desktop.
@RunWith(AndroidJUnit4::class)
class MyFragmentTest {
@Test
fun buttonIsEnabled() {
TestMyFragment.testViewModel = MyViewModel().also
it.updateState(enabled = true)
}
launchFragmentInContainer<TestMyFragment>()
onView(withId(R.id.button)).check(matches(isEnabled()))
}
@Test
fun buttonIsDisabled() {
TestMyFragment.testViewModel = MyViewModel().also
it.updateState(enabled = false)
}
launchFragmentInContainer<TestMyFragment>()
onView(withId(R.id.button)).check(matches(not(isEnabled())))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment