https://kotlinlang.org logo
#test
Title
# test
s

Smorg

01/04/2019, 7:25 AM
Hi guys, I am currently using
mockito-kotlin
in my project, and I saw from the docs that I can assign a property to a mock without actually having to use stubs. But this does not seem to be working in my code.
Copy code
@Test
fun testCase() {
    val entity = mock<Entity>()
    entity.property = Property()
    assert(entity.property != null) // fails
}
Or does it only work with primitive types or interfaces?
d

Daniel

01/04/2019, 11:02 AM
Maybe I missed this, but since mockito-kotlin is just a warpper around kotlin it should not be possible to use anything other than
whenever(entity.property).thenReturn(Property())
Or
mock<Entity> { on { property } doReturn Property() }
for short
3 Views