我想写一个单元测试,并做到这一点我正在写一个Mockito模拟的声明,但我似乎无法得到日食认识到我的返回值有效。不能返回Class对象与Mockito
下面是我在做什么:
Class<?> userClass = User.class;
when(methodParameter.getParameterType()).thenReturn(userClass);
的.getParameterType()
返回类型为Class<?>
,所以我不明白为什么日食说,The method thenReturn(Class<capture#1-of ?>) in the type OngoingStubbing<Class<capture#1-of ?>> is not applicable for the arguments (Class<capture#2-of ?>)
。它提供了投射我的用户类,但这只是让一些乱码东西eclipse说它需要再次施放(并且不能施放)。
这是Eclipse的问题,还是我做错了什么?
是的,它似乎必须是一个问题与日食或mockito。我能够实施你的建议,并解决了这个问题,所以谢谢! – CorayThan
@CorayThan它不是Eclipse。这在Intellij中也不能编译。 –
在NetBeans中一样。 –