This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun test() { | |
| arrange { | |
| mockSomething() | |
| mockSomethingElse() | |
| } | |
| act { | |
| doSomething() | |
| doSomethingElse() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun performChainedCalculationsCorrectly() { | |
| arrange { | |
| enterFormula("((515 + 87 x 311) - 302) ÷ 27") | |
| } | |
| act { | |
| performCalculation() | |
| } | |
| assert { | |
| resultIs("1010.0") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun shouldCalculateExpressionsCorrectly() { | |
| arrange { | |
| enterFormula("((515 + 87 x 311) - 302) ÷ 27") | |
| } | |
| act { | |
| performCalculation() | |
| } | |
| assert { | |
| assertResultIs("1010.0") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CalculatorScreenTest { | |
| @get:Rule | |
| val composeRule = createAndroidComposeRule(MainActivity::class.java) | |
| private val robot = CalculatorScreenRobot(composeRule) | |
| private fun arrange(block: CalculatorScreenRobot.Arrange.() -> Unit) = | |
| robot.Arrange().apply(block) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CalculatorScreenTest { | |
| @get:Rule | |
| val composeRule = createAndroidComposeRule(MainActivity::class.java) | |
| @Test | |
| fun shouldCalculateExpressionsCorrectly() { | |
| // arrange | |
| enterFormula("((515 + 87 x 311) - 302) ÷ 27") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CalculatorScreenRobot( | |
| private val composeRule: AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity> | |
| ) { | |
| inner class Arrange { | |
| fun enterFormula(formula: String) { | |
| formula.forEach { character -> | |
| if (!character.isWhitespace()) { | |
| val buttonLabel = when (character) { | |
| '(', ')' -> "()" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CalculatorScreenRobot { | |
| class Arrange {} | |
| class Act {} | |
| class Assert {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun shouldCalculateExpressionsCorrectly() { | |
| // arrange | |
| enterFormula("((515 + 87 x 311) - 302) ÷ 27") | |
| // act | |
| performCalculation() | |
| // assert | |
| assertResultIs("1010.0") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CalculatorScreenTest { | |
| @get:Rule | |
| val composeRule = createAndroidComposeRule(MainActivity::class.java) | |
| /** | |
| * type ((515 + 87 x 311) - 302) ÷ 27 | |
| * hit = | |
| * assert result is 1010.0 | |
| */ |