In Kotlin Multiplatform for Mobile, how we can wri...
# multiplatform
p
In Kotlin Multiplatform for Mobile, how we can write unit test to check intermediate values of
KLiveData
, can anyone give an example ?
z
this is very vague and stackoverflow-y. You’re going to have better luck by being more detailed and describing what you’ve already done, rather than asking people to do the work for you
a
I’m not sure what
KLiveData
is, is it the same as
LiveData
? There are lots of examples of
LiveData
being test in GitHub code - maybe one of them helps https://github.com/search?q=livedata+lang%3Akotlin+path%3A**%2F*Test*&type=code
p
Sorry for being too short on my query. I am referring to KLiveData. Also I am relatively new in Kotlin and Kotlin Multiplatform for Mobile (KMM). I am able to write unit test in KMM for ViewModels which has LiveData and able to test various scenarios. What I am looking for is to test intermediate values for LiveData. For ex: when an api call is sent then we have an intermediate state as Loading in LiveData so I am not sure how to write unit test to check these intermediate values. I see that the LiveData has
observeForever
and
observe
methods but not able to figure out how to use them to check intermediate values.