Stylianos Gakis
06/16/2022, 7:47 AMrunTest
function when coroutines have now their own runTest
as well? And I am not talking just about the name being the same, which is possibly okay if people are aware that they are different things, but also about including coroutine’s runTest
functionality. The powers it gives you like automatic skipping delays, access to advanceUntilIdle
and such have been very helpful for us in our tests, to make them easier to reason about. See example.
I am now at a point where I am using apollo’s runTest at some test but would also like to be able to use coroutine’s runTest, and I was thinking maybe apollo’s runTest can use coroutines runTest instead of runBlocking under the hood at some point? Or do you feel like this can’t/shouldn’t happen?bod
06/16/2022, 7:56 AMrunTest
exists because of the specifics of how coroutines / threading work on native, which has restrictions due to the current memory model. That means we should be able to revamp this when we switch to the new memory model - which we plan to do at some point in the future 🙂.mbonnin
06/16/2022, 8:15 AMrunTest
?Stylianos Gakis
06/16/2022, 8:15 AMrunTest
impl take care of said native intricacies? Since it’s like the way to run tests with coroutines in the latest version. Or does this have something with how apollo is handling threading?mbonnin
06/16/2022, 8:16 AMStylianos Gakis
06/16/2022, 8:21 AMbod
06/16/2022, 8:24 AMmbonnin
06/16/2022, 8:26 AMbod
06/16/2022, 8:28 AMStylianos Gakis
06/16/2022, 8:32 AMmbonnin
06/16/2022, 8:37 AMif you’d need to keep somehow a way open to port such fixes to the version that’d still support the old mm or if it’d just get abandoned completelyDepends the community feedback. 2.x is still widely used because it's used in some crazy huge codebases where migration takes time and also it's used by Java folks who don't want to pull the coroutines dependency so there is demand for maintainance release. I suspect demand will be much lower for old mm maintainance as the K/N user base is usually moving really fast ⚡ . But if there is demand I guess we can still patch
Maybe deprecating it in favor of just using the coroutines one?Yup, that ☝️
Stylianos Gakis
06/16/2022, 8:38 AMmbonnin
06/16/2022, 8:39 AMrunTest
topic, any reason to use advanceUntilIdle
instead of "just" waiting for viewModel.viewState
to change?advanceUntilIdle
because they introduce a behaviour that's specific to testsStylianos Gakis
06/16/2022, 8:43 AMmbonnin
06/16/2022, 8:50 AMviewModel.submitCode("123456")
val newState = withTimeout(2000) {
viewModel.viewState.drop(1).first()
}
assertThat(newState.loadingCode).isEqualTo(true)
assertThat(newState.loadingResend).isEqualTo(false)
viewState
is emitted