반환 나는 다음과 같은 단위 테스트가 있습니다mockito - 다음 오류
@Test
public void testGenerateFileName(){
GregorianCalendar mockCalendar = Mockito.mock(GregorianCalendar.class);
Date date = new Date(1000);
Mockito.when(mockCalendar.getTime()).thenReturn(date);
...
}
세 번째 줄에서 나는 다음과 같은 오류가 점점 오전 :
org.mockito.exceptions.misusing.WrongTypeOfReturnValue: Date cannot be returned by getTimeInMillis() getTimeInMillis() should return long
*** If you're unsure why you're getting above error read on. Due to the nature of the syntax above problem might occur because:
1. This exception *might* occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing.
2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies -
- with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.
왜 이런 일이 있습니까? getTimeInMillis()
을 사용하고 있지 않습니다.