Hadi Tok
07/12/2018, 8:21 AMoleksiyp
07/12/2018, 8:23 AM@After
Hadi Tok
07/12/2018, 8:27 AMHadi Tok
07/12/2018, 8:35 AMObserver.test()
LeoColman
07/12/2018, 12:25 PMHadi Tok
07/13/2018, 12:49 PMLeoColman
07/13/2018, 1:34 PMLeoColman
07/13/2018, 1:35 PMLeoColman
07/13/2018, 1:35 PMHadi Tok
07/14/2018, 8:14 AMghedeon
07/18/2018, 8:12 PMpublic class Foo {
private Bar bar;
public Bar getBar() {
return bar;
}
}
==========
val foo = mockk<Foo>()
every { foo.bar } returns mockk() // foo.bar is not mocked and remains null
ghedeon
07/18/2018, 8:14 PMbar
it works.ghedeon
07/18/2018, 8:15 PMdave08
07/18/2018, 8:16 PMval bar
, maybe that's the problem?dave08
07/18/2018, 8:16 PMghedeon
07/18/2018, 8:18 PMfoo.getBar()
is getting mocked, but not the foo.bar
)ghedeon
07/18/2018, 8:19 PMdave08
07/18/2018, 8:23 PMghedeon
07/18/2018, 8:27 PMFoo
class that is used in my test. All I want to do is to mock its public methods. I'm pretty sure it's one of the most basic cases you can have in your test)dave08
07/18/2018, 8:59 PMfoo.getBar()
is getting mocked, but not the foo.bar
)" you weren't trying to mock the private bar? Oh you mean when yoou use bar as getBar() in you kotlin test code... I seem to remember that when referring to a java property, the getXXX version is also there just the property version is suggested did you try using that one?ghedeon
07/18/2018, 9:04 PMevery { foo.getBar() }...
. And the foo.getBar()
is getting mocked. But that doesn't help me, because in code the foo.bar
is used and it's ignored by Mockkdave08
07/18/2018, 9:14 PMoleksiyp
07/19/2018, 1:52 PMoleksiyp
07/19/2018, 1:52 PMghedeon
07/19/2018, 1:57 PMFoo
in an empty class with one getter.oleksiyp
07/19/2018, 1:59 PMoleksiyp
07/19/2018, 2:00 PMoleksiyp
07/19/2018, 2:00 PMghedeon
07/19/2018, 2:03 PMval item = slot<Item>()
every { observer.onChanged(capture(item)) } just Runs
...
assert(item.captured.foo).toBe(expectedFoo)
Compared to mockito:
verify(observer).onChanged(argForWhich { foo == expectedFoo })
Is it possible to have it less verbose with Mockk? Somehow in-place, similar to mockito exampleoleksiyp
07/19/2018, 2:03 PM