Hata ayrıntısı:
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.
benim kodum:
@InjectMocks
protected ItemArrangeManager arrangeManagerSpy = spy(new ItemArrangeManagerImpl());
@Mock
protected JuItemWriteService juItemWriteService;
when(arrangeManagerSpy
.updateItemAttributes(mapCaptor.capture(), eq(juId), eq(itemTO.getSellerId())))
.thenReturn(false);
Gördüğünüz gibi, whenaçık değil updateItemAttributes(a döndürür boolean) diye sesleniyorum updateItemAttributesByJuId.
- Neden mockito bir dönmeye çalışıyor
booleandenupdateItemAttributesByJuId? - Bu nasıl düzeltilebilir?
@Repositoryile bazı Spring DAO yöntemlerini test ederken de bu sorunu yaşıyordum . yaparsamwhen(someDao.someMethod()).thenReturn(List<xxx>), bu WrongTypeOfReturnValue istisnasını aldım. Hata ayıklama yoluyla,someMethodyöntemin aslında yukarıdaki ifadede çağrıldığını ve Around Advice'ı tetiklediğini ve bir geri döndüğününullancak Mockito'nun birList<xxx>.