Skip to content

Instantly share code, notes, and snippets.

@birojow
Last active July 7, 2024 13:51
Show Gist options
  • Select an option

  • Save birojow/c421cffab054ab93bda9cee459bab1db to your computer and use it in GitHub Desktop.

Select an option

Save birojow/c421cffab054ab93bda9cee459bab1db to your computer and use it in GitHub Desktop.
class CalculatorScreenTest {
@get:Rule
val composeRule = createAndroidComposeRule(MainActivity::class.java)
/**
* type ((515 + 87 x 311) - 302) ÷ 27
* hit =
* assert result is 1010.0
*/
@Test
fun shouldCalculateExpressionsCorrectly() {
composeRule
.onNodeWithText("()")
.performClick()
composeRule
.onNodeWithText("()")
.performClick()
composeRule
.onNodeWithText("5")
.performClick()
composeRule
.onNodeWithText("1")
.performClick()
composeRule
.onNodeWithText("5")
.performClick()
composeRule
.onNodeWithText("+")
.performClick()
composeRule
.onNodeWithText("8")
.performClick()
composeRule
.onNodeWithText("7")
.performClick()
composeRule
.onNodeWithText("x")
.performClick()
composeRule
.onNodeWithText("3")
.performClick()
composeRule
.onNodeWithText("1")
.performClick()
composeRule
.onNodeWithText("1")
.performClick()
composeRule
.onNodeWithText("()")
.performClick()
composeRule
.onNodeWithText("-")
.performClick()
composeRule
.onNodeWithText("3")
.performClick()
composeRule
.onNodeWithText("0")
.performClick()
composeRule
.onNodeWithText("2")
.performClick()
composeRule
.onNodeWithText("()")
.performClick()
composeRule
.onNodeWithText("÷")
.performClick()
composeRule
.onNodeWithText("2")
.performClick()
composeRule
.onNodeWithText("7")
.performClick()
composeRule
.onNodeWithText("=")
.performClick()
composeRule
.onNodeWithText("1010.0")
.assertIsDisplayed()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment