Manuel Lorenzo
11/15/2020, 8:22 PMManuel Lorenzo
11/16/2020, 8:48 AMkevin.cianfarini
11/16/2020, 7:19 PMTurbine
by square. It's fantastic. https://github.com/cashapp/turbinekevin.cianfarini
11/16/2020, 7:19 PMrunBlocking
for your testskevin.cianfarini
11/16/2020, 7:20 PMviewModelScope
. Testing becomes a bit easier if you inject a scope into the viewmodel via dependency injection and then implement CoroutineScope
via interface delegationkevin.cianfarini
11/16/2020, 7:20 PMkevin.cianfarini
11/16/2020, 7:20 PMclass MyViewModel @Inject constructor(
@Named("viewModelScope") scope: CoroutineScope
) : ViewModel(), CoroutineScope by scope {
override fun onCleared() {
super.onCleared()
cancel()
}
}
@Test fun testFoo() = runBlocking { // this: CoroutineScope
val viewModel = MyViewModel(this)
viewModel.someFlow.test { ... }
}
Manuel Lorenzo
11/17/2020, 1:20 PMjava.lang.NoSuchMethodError: app.cash.turbine.FlowTurbineKt.test-f_gJSvk$default(Lkotlinx/coroutines/flow/Flow;DLkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
kevin.cianfarini
11/17/2020, 1:26 PMtestImplementstion
? Also you can try asking questions over at #squarelibrariesManuel Lorenzo
11/17/2020, 4:10 PMManuel Lorenzo
11/17/2020, 4:10 PM