Mockito 3.1 VerificationWithTimeout.never 备选方案

Mockito 3.1 VerificationWithTimeout.never Alternative

我会使用 Mockito 来验证方法 onMethodCall 从未在存根 listener 上调用过。在以前版本的 Mockito 上,我可以使用 VerificationWithTimeout.never() 方法如下:

verify(listener, timeout(100).never()).onMethodCall()

不过这个方法似乎在 Mockito 3.1 中被移除了。我怎样才能在 mockito 3.1 中实现这一点?

发现正确的使用方法是after(100).never().

有一条来自 Mockito 的消息解释了 timeout().never() 方法的删除。

timeout() should not be used with atMost() or never() because...
...it does not make much sense - the test would have passed immediately in concurrency
We kept this method only to avoid compilation errors when upgrading Mockito.
In future release we will remove timeout(x).atMost(y) from the API.
If you want to find out more please refer to issue 235```