It would be better if you provide complete example including mock creation and stubbing.
But anyway, if you want your mocked objects to behave as original objects you should either use
spyk
or stub method call with
callOriginal()
. Otherwise, mock will either fail or return
null
based on whether it is relaxed or not.
So, make sure your stubbing block contains at least this:
Copy code
every { viewModel.dataLiveData.postValue(any()) } answers { callOriginal() }
Then, based on your mock creation logic you might need to also stub