รายละเอียดข้อผิดพลาด:
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 จึงพยายามส่งคืน a
booleanfromupdateItemAttributesByJuId? - จะแก้ไขได้อย่างไร?
@Repositoryวิธี DAO กับ@Aspect ถ้าฉันทำwhen(someDao.someMethod()).thenReturn(List<xxx>)ฉันได้รับข้อยกเว้น WrongTypeOfReturnValue นี้ ผ่านการดีบักฉันเห็นได้ว่าsomeMethodวิธีนี้ถูกเรียกใช้จริงในข้อความข้างต้นและเรียกใช้คำแนะนำรอบ ๆ และส่งคืนnullแต่ Mockito คาดหวังว่าจะมีList<xxx>ไฟล์.