As probably stated by the error message, you can not mix matchers and fixed values (no matcher), like this:when(restTemplate.exchange(any(URI.class), any(HttpMethod.class), headersString , SomeObject.class)).// ^^ ^^您必须将 eq()匹配器用于固定值,例如:You have to use the eq() matchers for fixed values, like this:when(restTemplate.exchange(any(URI.class), any(HttpMethod.class), eq(headersString), eq(SomeObject.class))).来自 Matchers javadoc:From the Matchers javadoc: 警告:如果使用参数匹配器,则所有参数都必须由匹配器提供.If you are using argument matchers, all arguments have to be provided by matchers. 这篇关于如何使用Mockito模拟Rest模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-27 01:02