mockito-kotlin icon indicating copy to clipboard operation
mockito-kotlin copied to clipboard

spy call real method for doReturn when

Open ericntw opened this issue 5 years ago • 2 comments
trafficstars

It's unexpected because:

val someObject = Mockito.spy(SomeClass(dependency1, dependency2))
// ...
Mockito.doReturn(someResult).`when`(someObject).someMethod(param1)

Does not call the real someMethod

Or is this library's spy is intended to work differently from Mockito's spy? 🤔

ericntw avatar Feb 14 '20 03:02 ericntw

@ericntw Sounds like a duplicate of either #319 or #369. What's the output of your test?

bohsen avatar Feb 15 '20 11:02 bohsen

Check answer here.

bohsen avatar Feb 15 '20 11:02 bohsen