Alexa_Gal
09/22/2021, 7:10 PMandroidTest
and im having some problems trying to mock the ViewController of my view, maybe im doing something working but i would like to test only the view without the view controller (i already have the Unit test for my view controller)
how would you do it using hilt and compose-navigation (HiltAndroidTest
)Peter Mandeljc
09/23/2021, 1:46 PMfun LoginScreen(vm: LoginViewModel = hiltViewModel(), onPopBack: () -> Unit) {
val state by vm.anyState.collectAsState()
LoginView(state, onPopBack)
}
// Test this
fun LoginView(anyStateFromVM: ?, onPopBack: () -> Unit) {
// ...
}
Alexa_Gal
09/23/2021, 4:33 PMdoLogin: vm.doLogin...
?Peter Mandeljc
09/23/2021, 5:03 PMLoginView(state, onPopBack, onLogin: vm::onLogin)
Alexa_Gal
09/23/2021, 5:04 PMPeter Mandeljc
09/23/2021, 5:05 PMAlexa_Gal
09/23/2021, 5:05 PMPeter Mandeljc
09/23/2021, 5:07 PMLoginViewModel()
, you don't need to call hiltViewModel<LoginViewModel>()
Alexa_Gal
09/23/2021, 5:10 PMPeter Mandeljc
09/23/2021, 5:11 PM