我正在尝试模拟Calendar.getInstance()
以进行单元测试。
因此,我正在使用PowerMock(powermock-core:2.0.4
&powermock-module-junit4:2.0.4
)及其Mockito API(powermock-api-mockito2:2.0.4
)。
[我很清楚类似的情况do exist,但是我面临的例外似乎没有出现在其他人的情况下。
实际上是在做时
mockStatic(Calendar.class);
when(Calendar.getInstance()).thenReturn(aCalendar);
在带有]的类中的测试方法上>
@RunWith(PowerMockRunner.class) @PrepareForTest({DateUtils.class})
我收到以下错误:
org.mockito.exceptions.misusing.NotAMockException: Argument should be a mock, but is: class java.lang.Class
。
我做错了什么以及如何解决?
谢谢
我正在尝试模拟Calendar.getInstance()以进行单元测试。因此,我正在使用PowerMock(powermock-core:2.0.4&powermock-module-junit4:2.0.4)及其Mockito API(powermock-api-mockito2:...
这里有几个问题。