Erik
11/03/2020, 7:34 PMTestCoroutineScope / -Dispatcher with runBlockingTest, when you flow.launchIn(testScope), then the job would leak unless you remember to cancel the job before the test block ends. How can you verify more easily that a flow emitted certain values? I can think of some solutions:
1. As a side effect, put collected values in some mutable collection. This makes assertion of values easy, but you still have to remember to cancel any collectors of the uncompleted flow.
2. Cancel the source of the flow, i.e. force it to complete, by the end of the test. This should usually also complete collectors.
3. Do not use the test coroutine scope to collect flows that do not complete. This has a downside that you test with multiple scopes, which may be conceptually challenging.
Either way it's a bit of test boilerplate 👎 Any ideas?Ian Lake
11/03/2020, 7:38 PMflosch
11/03/2020, 7:41 PMTestFlow from https://github.com/floschu/coroutines-test-extensions can also help youAdam Powell
11/03/2020, 7:41 PMErik
11/03/2020, 7:42 PMErik
11/03/2020, 7:43 PMdave08
11/25/2020, 11:24 AMtest { } needs to be run before the When and IS the Then already... 🤕Erik
11/25/2020, 11:43 AMdave08
11/25/2020, 11:50 AMtestIn whereas with Turbine, you need to launch yourself...
Did you end up using Turbine, Erik?Erik
11/25/2020, 11:51 AMdave08
11/25/2020, 12:05 PMflosch
11/25/2020, 12:14 PMTestCoroutineScope to launch the TestFlow in, also allows to test timing due to the DelayControllerdave08
11/25/2020, 12:24 PM