当我运行 mockito 测试时,发生 ErrorTypeOfReturnValue 异常
错误详细信息:
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);
如您所见,我调用(确实返回一个)而不是。when
updateItemAttributes
boolean
updateItemAttributesByJuId
- 为什么 Mockito 试图从 中返回 ?
boolean
updateItemAttributesByJuId
- 如何纠正这种情况?