Amazing video! Thank you for explaining this. One doubt: So, if we move away from coroutines, livedata to something else, our Unit Tests needs to be changed as well. Aren't Unit tests suppose to be independent of the implementation details?
bro, really thank you! finally made my viewmodel tests work, all I was missing was this dispatcher.scheduler.advanceUntilIdel() function before doing the assertions, thank you! new subscriber here!
Hi, I am having a problem that my viewModel uses the function init{} and it is pointing that I Method getMainLooper in android.os.Looper not mocked. for this, any tips?
I would recommend injecting a dispatcher as an argument to the viewModel, then you can easily replace it for a Test dispatcher for unit tests, see it here: developer.android.com/kotlin/coroutines/coroutines-best-practices
Conteúdo de primeira linha!! Tem pouquíssimo conteúdo por aí sobre testes no Android e vc me ajudou muito nesse vídeo, valeuu
Que vídeo bom mano!!! Por favor, faz uma série de test em android, tem pouquissimo conteúdo sobre.
Amazing video! Thank you for explaining this.
One doubt: So, if we move away from coroutines, livedata to something else, our Unit Tests needs to be changed as well. Aren't Unit tests suppose to be independent of the implementation details?
great video great explaination of unit test. I learned a lot from this awesomevideo thank you bro!
Happy to read this!
bro, really thank you! finally made my viewmodel tests work, all I was missing was this dispatcher.scheduler.advanceUntilIdel() function before doing the assertions, thank you! new subscriber here!
Happy to help! Subscribing would help the channel if you can :)
@@Renaro yeah, already subscribed! :)
Great but could we use this dispatcher for Instrumented tests? I love to see AndroidTests (instrumented) tests. Very few example on that.
Hey Firas, for Instrumented tests you don't need it, you can mock the responses of your ViewModel. I will create a video about that!
@@Renaro So grateful. I know Mockk or Mockitp are there to help.
Another treasure I just found.
this only check for state change but how we verify the livedata changed with observer?
I am having trouble testing cold flows. Stateflow create with stateIn function.
I need to collect it first before I can check it new not initial value
Hi, I am having a problem that my viewModel uses the function init{} and it is pointing that I Method getMainLooper in android.os.Looper not mocked. for this, any tips?
I would recommend injecting a dispatcher as an argument to the viewModel, then you can easily replace it for a Test dispatcher for unit tests, see it here:
developer.android.com/kotlin/coroutines/coroutines-best-practices
@@Renaro Thank you very much Renaro, what I did was instantiate my view model inside my setup function after Dispatchers.setMain(dispatcher)
great video. I have learned more, You have another about Unit tests and UI tests can share me
Dude, thank you!
You're awesome ❤
❤
nice video, thanks
A lot of boiler plate code to use observer in the test class, instead create a separate LiveDataUtil file
Indeed that could help!