can anyone recommend mocking library for kotlin ?
# android
r
can anyone recommend mocking library for kotlin ?
d
rwachol: Either Mockito or JMockit
r
I had problem with final classes but got through
d
I've used both and Mockito is more popular and I find it easier to use, plus it has a library for easier kotlin use
r
yes, I was using mockito in that project but I was wondering if I’d have to add powermock too
d
nope, there is an experimental extension for mockito that you can use
let me find the doc on it
in short, it lets you mock finals without powermock
there ya go
Mocking of final classes and methods is an incubating, opt-in feature. It uses a combination of Java agent instrumentation and subclassing in order to enable mockability of these types. As this works differently to our current mechanism and this one has different limitations and as we want to gather experience and user feedback, this feature had to be explicitly activated to be available ; it can be done via the mockito extension mechanism by creating the file src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker containing a single line:
mock-maker-inline
i use it and have no trouble using it with kotlin
r
yeah I’ve seen that. makes compilation longer