模拟暂停永远不会返回

mid*_*ght 2 mockito kotlin-coroutines

我想模拟一个挂起函数以永远不返回任何结果。与此类似的是 的用法Single.never()

是否可以?

Art*_*mes 6

我的团队通过一个suspendCancellableCoroutine从不调用的方法实现了这一点resume()。像这样的东西:

suspend fun never(): Nothing = suspendCancellableCoroutine { }
Run Code Online (Sandbox Code Playgroud)