Last active
July 30, 2020 09:35
-
-
Save manhduy/3655da93b46b78eb7b374581edf902de to your computer and use it in GitHub Desktop.
This file contains 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
@Before | |
fun setUp() { | |
calculatorService = mockk<CalculatorService>() | |
viewModel = CalculatorViewModel(calculatorService) | |
} | |
@Test | |
fun test_SumReturnFromCalculator_LiveDataChanged() { | |
//Given | |
every { calculatorService.sum(a, b) } returns sum | |
//When | |
viewModel.onSumClick(textA, textB) | |
//Then | |
verify { calculatorService.sum(a, b) } | |
assertEquals(sum, viewModel.sum.getOrAwaitValue()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment