07-20-2023, 03:01 PM
We had a few tests in Java and Mockito, which we are progressively converting into Kotlin and Mockk. There's a problem, though. This simple line:
`verify(mockedInteractor).setIndex(1);`
When we move it to mockk, we get this:
`verify { mockedInteractor.index = 1 }`
This of course passes the tests, as it's not actually checking that `index` was set to 1. It's simply setting the mock's variable to 1. This below has the same effect.
`verify { mockedInteractor.setIndex(1) }`
Is there a way to verify setters?
`verify(mockedInteractor).setIndex(1);`
When we move it to mockk, we get this:
`verify { mockedInteractor.index = 1 }`
This of course passes the tests, as it's not actually checking that `index` was set to 1. It's simply setting the mock's variable to 1. This below has the same effect.
`verify { mockedInteractor.setIndex(1) }`
Is there a way to verify setters?