Hi guys, I am trying to use mock-maker-inline to a...
# android
m
Hi guys, I am trying to use mock-maker-inline to allow mocking of kotlin classes with mockito ( https://github.com/mockito/mockito/wiki/What's-new-in-Mockito-2#mock-the-unmockable-opt-in-mocking-of-final-classesmethods ) But then I am having issues with old tests. So, when I try to do something like
verify(adapter).notifyItemMoved(0, 0);
where
adapter
is
RecyclerView.Adapter
I am getting error this error might show up because you verify either of: final/private/equals()/hashCode() methods. Did anyone had similar issue ?
đź‘Ť 1
a
I had the exact same problem the other day, and I discovered it was being caused by using Robolectric in conjunction with Mockito. The weird thing is that the tests that were failing were tests of pure java. The only way I got it to work was to remove Robolectric and the tests that relied on it and then the pure java tests worked. Not sure if you are using robolectric, but this was my problem.
m
Yup, I am using roboelectric. So, you couldn’t figure out the way to work together ? Anyhow thanks
a
I wasn’t able to figure it out. I was only able to use Mockito or Robolectric, but not both at the same time. I’m using the mockito extension that allows mocking of final classes and I’m thinking maybe that is interfering with Robolectric’s functionality.
g
Is that instrumentation tests? Inline mock maker works only on JVM so you can use it only for unit tests, machinery used to mock final classes by mockito doesn't available on Dalvik/ART
a
@gildor my problem was with normal unit tests, not integration tests.
m
@gildor same here