Open ppamorim opened 4 years ago
Sorted with the use of `when`(messages.iterator()).thenAnswer { messagesList.iterator() }
. Is this correct?
@ppamorim Yes, given the explanation in https://stackoverflow.com/a/63064586/6834276 that seems correct.
I guess our example works since it doesn't hit the mocked call multiple times, hence only iterates the list a single time. I guess we should update the example.
This code below does not work when using realm-java in a Kotlin project since high order functions from Kotlin are not automatically handled by this solution that uses the interactor:
https://github.com/realm/realm-java/blob/0ddcc16136d31984aaaec7387a552c1d31a5ccb9/examples/unitTestExample/src/test/java/io/realm/examples/unittesting/ExampleActivityTest.java#L167
A structure as the example below does not work:
I am not sure how this could be sorted, I also opened an issue in the mockito-kotlin repo: https://github.com/nhaarman/mockito-kotlin/issues/385 Also added a question on StackOverflow: https://stackoverflow.com/questions/63042724/how-to-mock-kotlins-list-foreach