David Kirchner
1 min readJul 12, 2018

--

mockito now supports mocking final classes natively, although you have to opt-in (and be aware of the possible downsides): https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2#unmockable

Personally, I still use fromJson for this specific use case — verifying I do the right thing with data returned from the API, occasionally verifying malformed JSON handling — but outside of that I mock final Kotlin classes all the time.

--

--