Fixed
Status Update
Comments
ia...@gmail.com <ia...@gmail.com> #2
Yigit, do you have time to fix it?
reemission of the same liveData is racy
reemission of the same liveData is racy
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
mg...@google.com <mg...@google.com>
mg...@google.com <mg...@google.com>
ap...@google.com <ap...@google.com> #3
yea i'll take it.
ap...@google.com <ap...@google.com> #4
Thanks for the detailed analysis. This may not be an issue anymore since we've started using Main.immediate there but I' not sure; I'll try to create a test case.
ap...@google.com <ap...@google.com> #5
just emitting same live data reproduces the issue.
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
Description
Component used:
androidx.lifecycle
Version used:
2.5.1
Devices/Android versions reproduced on: n/a
It's common to test view models in use tests but there is currently no way to close a view model without creating a VM Store, Factory etc. It would be nice if there was a test artifact that could help you provide a view model and close it.