I don't have any experience with mockito, but you ...
# announcements
r
I don't have any experience with mockito, but you can try asking in #C9EJFT6DB
z
I saw the channel but it's not active 😕
r
Yeah, that's the sad reality of this slack. Lots of channels are more or less abandoned. Did you try #C0NBD4UF8?
z
I'll try now, thanks!
👍 1
n
did you call
MockitoAnnotations.initMocks(this)
? You need to do that for the
@Mock
annotation to work
z
Nope 😄
But it works for everything else
n
I usually prefer just
mock<Type>()
🙂
z
Yes, I'm using this library, but why do I need to do it? I have tens of tests without calling initMocks
n
it isn’t
open
mockito can only mock
open
functions and properties
z
I'm using
kotlin-spring
plugin
n
by default everything in kotlin is
final
and mockito cannot mock them (unless you configure it)
at least, I think that might be the issue 😮
z
It could be, but
kotlin-spring
makes everything open 😕
Also this test was passing before I converted the instance to extend an abstract class
n
hmm, I’ve never used kotlin-spring so didn’t know that
maybe
kotlin-spring
doesn’t do that for abstract classes?
try making it open and see what happens
though abstract should be open by default I would imagine, or else how do you override 😄
z
with open it works -.-
thanks!
n
¯\_(ツ)_/¯
z
But it's super ugly this way...
n
Maybe have a google around abstract with the
kotlin-spring
plugin, might be a known issue with workarounds
j
doesn’t kotlin-spring just open the Spring-annotated classes, like @Component etc. ? you can add mockito-inline to your test dependencies to allow you to mock final classes