You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a case where i need to call 3 api's once Screen is launched.
So I have written a method like this
fun fetchAllApis() {
fetchApi1()
fetchApi2()
fetchApi3()
}
and this method is called inside init block of ViewModel
init {
fetchAllApis()
}
Now the issue is, When i want to write unit test case for method fetchApi1() , I have to instantiate ViewModel which. internally calls init block and runs all the apis.
I want to mock init block. When ever I create instance of ViewModel, It should not call fetchAllApis() method.
Is there any way i can achieve this?
I tried by using constructor mock, but did work.
The text was updated successfully, but these errors were encountered:
I have a case where i need to call 3 api's once Screen is launched.
So I have written a method like this
and this method is called inside init block of ViewModel
Now the issue is, When i want to write unit test case for method fetchApi1() , I have to instantiate ViewModel which. internally calls init block and runs all the apis.
I want to mock init block. When ever I create instance of ViewModel, It should not call fetchAllApis() method.
Is there any way i can achieve this?
I tried by using constructor mock, but did work.
The text was updated successfully, but these errors were encountered: