Possibly a dumb question, but does anyone here hap...
# mockk
p
Possibly a dumb question, but does anyone here happen to know if there’s a way to mock constructors that doesn’t result in the underlying class’s real constructor actually being called?  From what I can tell (somewhat astonishingly), the default behavior of mockkConstructor() is to actually call a real constructor, then discard its output and substitute a mockk singleton.  This is somewhat disappointing, since it suggests that you can’t actually mock constructors with mockkConstructor() (ie, that unwanted side-effects will still occur)
e
working as documented: https://mockk.io/#constructor-mocks
just after the constructor of the mocked class is executed, objects become a
constructed mock
p
yeah. I guess I’m just trying to get a sense of the reason why that’s the case, and if there’s a workaround.