You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that if a Flow is canceled "externally" (e.g. a StateFlow that is canceled only when the CoroutineScope it was launched in is canceled) then test and testIn do not behave the same.
While test reports all unconsumed events and fails the test, testIn does not and passes the test.
This is not necessarily caused by the backgroundScope as it can be replicated with a custom CoroutineScope() + scope.cancel() or even when canceling the Job the turbine was launched in.
I've figured out this behavior is caused by not handling CancellationException as a special case. From the docs of CancellationException: "It indicates normal cancellation of a coroutine".
The text was updated successfully, but these errors were encountered:
I've put up a PR that attempts to solve this issue.
I can't say I fully understand the library design and all the consequences this might entail, for example when used with some twisted combination with withTimeout. The library itself does a lot of work to differentiate withTimeout from withTurbineTimeout already and I just don't see that deep.
I've noticed that if a
Flow
is canceled "externally" (e.g. aStateFlow
that is canceled only when theCoroutineScope
it was launched in is canceled) thentest
andtestIn
do not behave the same.While
test
reports all unconsumed events and fails the test,testIn
does not and passes the test.This is not necessarily caused by the
backgroundScope
as it can be replicated with a customCoroutineScope()
+scope.cancel()
or even when canceling theJob
the turbine was launched in.I've figured out this behavior is caused by not handling
CancellationException
as a special case. From the docs ofCancellationException
: "It indicates normal cancellation of a coroutine".The text was updated successfully, but these errors were encountered: