Skip to content

Instantly share code, notes, and snippets.

@trietbui85
Last active July 29, 2020 13:42
Show Gist options
  • Save trietbui85/8f7beb9732e3b5b6a21fa3c58940b54a to your computer and use it in GitHub Desktop.
Save trietbui85/8f7beb9732e3b5b6a21fa3c58940b54a to your computer and use it in GitHub Desktop.
Unit test Android custom view with AndroidX Test and Robolectric
@Test
fun testButtonAddIsClicked() {
countView.reset()
buttonAdd.performClick()
assertThat(countView.countValue).isEqualTo(1)
assertThat(textViewValue.text.toString()).isEqualTo("1")
buttonAdd.performClick()
assertThat(countView.countValue).isEqualTo(2)
assertThat(textViewValue.text.toString()).isEqualTo("2")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment