I try to mock with mockito an object with this method:
public List<List<String>> readData(String range) throws IOException {
this is my mock definition:
final List<List<String>> excel = jsonUtility.excelFromJson("bla.json");
SpreadSheetHandlerImpl spreadSheetHandlerImpl = mock(SpreadSheetHandlerImpl.class);
when(spreadSheetHandlerImpl.readData(anyString()))
.thenReturn(excel);
why do i get this error?
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
ArrayList cannot be returned by toString()
toString() should return String
***
If you're unsure why you're getting above error read on.
Due to the nature of the syntax above problem might occur because:
1. This exception *might* occur in wrongly written multi-threaded tests.
Please refer to Mockito FAQ on limitations of concurrency testing.
2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies -
- with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.
as the signature returned type is List<List<String>>
Aucun commentaire:
Enregistrer un commentaire