gpt4 book ai didi

junit - mockito - 使用值列表中的一个值在匹配器中进行比较

转载 作者:行者123 更新时间:2023-12-04 18:03:45 25 4
gpt4 key购买 nike

我的方法接口(interface)是

Boolean isAuthenticated(String User)

如果任何用户从列表中传入函数,我想从值列表中进行比较,那么它应该返回 true。
when(authService.isAuthenticated(or(eq("amol84"),eq("arpan"),eq("juhi")))).thenReturn(true);

我正在使用附加参数匹配器“或”,但上面的代码不起作用。我该如何解决这个问题?

最佳答案

您可以定义单独的答案:

when(authService.isAuthenticated(eq("amol84"))).thenReturn(true);
when(authService.isAuthenticated(eq("arpan"))).thenReturn(true);
when(authService.isAuthenticated(eq("juhi"))).thenReturn(true);

关于junit - mockito - 使用值列表中的一个值在匹配器中进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36772523/

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