gpt4 book ai didi

java - org.hamcrest.Matchers.any 在 java 8 中不工作

转载 作者:行者123 更新时间:2023-12-01 19:57:22 26 4
gpt4 key购买 nike

Hamcrest Matchers any() 在 Java 8 中不起作用。

when(simpleJdbcCall.execute(Matchers.any(SqlParameterSource.class))).thenReturn(outputParameters);

any() 仅适用于已弃用的 org.mockito.Matchers。

在 Java 8 中还有其他方法使用此方法吗?

最佳答案

使用 Mockito 的 any(Class),而不是 Hamcrest 的

when(simpleJdbcCall.execute(Mockito.any(SqlParameterSource.class))).thenReturn(outputParameters);

您正在尝试让 Mockito 使用 Hamcrest 的方法。这是行不通的。因此,将您的调用从 Matchers.any(SqlParameterSource.class) 更改为 Mockito.any(SqlParameterSource.class)

关于java - org.hamcrest.Matchers.any 在 java 8 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49116086/

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