https://kotlinlang.org logo
#mockk
Title
# mockk
j

Joram Visser

07/09/2019, 10:54 AM
I am struggling with mocking the
foo
and
bar
in this example. The code in the snippet is not working. I also tried making use of
mockkConstructor()
function for the
ServiceLocator()
,
Foo()
and
Bar()
, which also didn’t work. So my question is; how can I set up the mocks correctly so that I can test
MyClass
without going out of the class.
w

wbertan

07/09/2019, 11:02 AM
Isn't the case where you are creating the
MyClass
before mocking the
ServiceLocator
object?
j

Joram Visser

07/09/2019, 11:04 AM
🤯
You are right.