Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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