Is there any way to check that a couroutineScope i...
# coroutines
p
Is there any way to check that a couroutineScope is cancelled? on my Unit test I want to check that my coroutineScope is cancelled at some point. The thing is my CoroutineScope is not a mock so I can not use verify.
e
there's
val CoroutineScope.isActive: Boolean
, is that enough for you?
otherwise you can chain together
Copy code
suspend val coroutineContext: CoroutineContext /* OR */ suspend fun currentCoroutineContext(): CoroutineContext
val CoroutineContext.job: Job
val Job.isCancelled: Boolean
p
I've thought about that
isActive
, but didn't know if it would do the job, I'm going to try it. But I want to check if it's called the
cancel()
at some point... So that's why I'd need the verify there
g
isActive is way to go, but it also will be false if Job is finished