https://kotlinlang.org logo
Title
r

rwachol

05/26/2017, 8:13 AM
can anyone recommend mocking library for kotlin ?
d

David W

05/26/2017, 11:41 AM
rwachol: Either Mockito or JMockit
r

rwachol

05/26/2017, 11:41 AM
I had problem with final classes but got through
d

David W

05/26/2017, 11:41 AM
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

rwachol

05/26/2017, 12:05 PM
yes, I was using mockito in that project but I was wondering if I’d have to add powermock too
d

David W

05/26/2017, 12:06 PM
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

rwachol

05/26/2017, 12:37 PM
yeah I’ve seen that. makes compilation longer