错误详情:
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
? - 如何纠正?
原文由 confused windbell 发布,翻译遵循 CC BY-SA 4.0 许可协议
根据 https://groups.google.com/forum/?fromgroups#!topic/mockito/9WUvkhZUy90 ,你应该改写你的
到