is it possible to use a verify block to test if a property was accessed?
Specifically I have something like this
Copy code
class Foo {
val prop get() = 1
}
val aFoo = Foo()
val myService = MyService(aFoo)
myService.method() // should access Foo::prop
verify {
aFoo.prop // doesn't work
}
m
Mattia Tommasone
12/10/2021, 11:03 AM
i think you can do
Copy code
verify {
aFoo getProperty prop
}
m
Mendess
12/10/2021, 11:04 AM
it doesn't work, it says
m
Matteo Mirk
12/10/2021, 11:33 AM
you need a spy, that’s why it doesn’t work:
val aFoo = spyk<Foo>()
this way the verification succeeds with both syntaxes, just choose one: