我想寫一個單元測試,並做到這一點我正在寫一個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中一樣。 –