【发布时间】:2012-06-20 14:26:33
【问题描述】:
错误详情:
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
Boolean cannot be returned by updateItemAttributesByJuId()
updateItemAttributesByJuId() should return ResultRich
This exception might occur in wrongly written multi-threaded tests.
Please refer to Mockito FAQ on limitations of concurrency testing.
我的代码:
@InjectMocks
protected ItemArrangeManager arrangeManagerSpy = spy(new ItemArrangeManagerImpl());
@Mock
protected JuItemWriteService juItemWriteService;
when(arrangeManagerSpy
.updateItemAttributes(mapCaptor.capture(), eq(juId), eq(itemTO.getSellerId())))
.thenReturn(false);
如您所见,我在updateItemAttributes 上调用when(它确实返回boolean)而不是updateItemAttributesByJuId。
- 为什么 Mockito 试图从
updateItemAttributesByJuId返回boolean? - 如何解决这个问题?
【问题讨论】: