Created
January 22, 2019 01:35
-
-
Save weverb2/a8de3418b6c493c10085c3fe382fb2c7 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
class MainViewModelTest { | |
@get:Rule | |
val instantTaskRule = InstantTaskExecutorRule() | |
@RelaxedMockK | |
lateinit var mockObserver: Observer<Boolean> | |
lateinit var viewModel: MainViewModel | |
@Before | |
fun setUp() { | |
MockKAnnotations.init(this) | |
viewModel = MainViewModel() | |
} | |
@Test | |
fun testValidation() { | |
viewModel.isFormValid.observeForever(mockObserver) | |
viewModel.username = "username1" | |
viewModel.password = "password1" | |
viewModel.username = "username" | |
verifyOrder { | |
mockObserver.onChanged(false) | |
mockObserver.onChanged(true) | |
mockObserver.onChanged(false) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment