त्रुटि विवरण:
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? - इसे कैसे ठीक किया जा सकता है?
@Repositoryसाथ कुछ स्प्रिंग डीएओ पद्धति का परीक्षण कर रहा था तो मुझे भी यह समस्या आ रही थी । यदि मैं करता हूं, तो मुझे यह गलत टाइपऑफ़ऑर्नेटवर्लव्यू अपवाद मिला। थ्रू डीबग, मैं देख सकता हूं कि विधि को वास्तव में उपरोक्त कथन में कहा गया है और लगभग सलाह देता है और वापस लौटता है लेकिन मॉकिटो एक उम्मीद कर रहा है ।when(someDao.someMethod()).thenReturn(List<xxx>)someMethodnullList<xxx>