gpt4 book ai didi

使用 isNull 时出现 Java UnfinishedVerificationException

转载 作者:太空宇宙 更新时间:2023-11-04 09:07:52 25 4
gpt4 key购买 nike

我有以下模拟:

when(manager.list(eq(userId), eq(0), isNull())).thenReturn(completedFuture(user));

// call some method

verify(configurationsManager).list(any(), any(), isNull());

当我运行这个时,我得到一个

org.mockito.exceptions.misusing.UnfinishedVerificationException: 
Missing method call for verify(mock) here:

它引用 verify(configurationsManager).list(any(), any(), isNull()); 行。我做错了什么?

list方法是:

public CompletionStage<User> list(UserId, int, Token)

其中 UserIdToken 是自定义类。

最佳答案

我认为您的问题可能是在匹配 list() 方法的第二个 int 类型变量时使用 any() 方法。根据我的经验,any() 方法往往不适用于原始类型。因此,我会使用 anyInteger() 来代替。因此,您的新行将是:

verify(configurationsManager).list(any(), anyInteger(), isNull());

关于使用 isNull 时出现 Java UnfinishedVerificationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60010741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com