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

bbaldino

08/26/2020, 11:14 PM
I'm running into some trouble trying to verify that a field was not set, am I using the wrong syntax?
Copy code
class Foo {
    var field: Int = 0
}

fun main() {
    val foo = spyk<Foo>()

    foo.field = 42

    // This works fine
    verify { foo setProperty "field" value 42 }
    // This should fail, but it throws "io.mockk.MockKException: can't find stub io.mockk.MockKMatcherScope$DynamicSetProperty@64a896b0"
    verify { foo setProperty "field" wasNot Called }
}
Looks like
verify(exactly = 0) { foo setProperty "field" value any<Int>() }
works
6 Views