Skip to content Skip to sidebar Skip to footer

Verify Method Called In Unit Testing Using Coroutine With Delay

I've been reading this article to understand how to unit test a coroutine that contains a delay and applied it, but I still don't understand why verify is being called before havin

Solution 1:

One idea could be to return the Job in method1 like the following:

funmethod1(): Job {
  return GlobalScope.launch {
    myDelayedMethod()
  }
}

And then replace method1() with method1().join(), so that runBlockingTest waits for the execution of the coroutine.

Post a Comment for "Verify Method Called In Unit Testing Using Coroutine With Delay"