I have defined my mock as follows:
private val dal = mockk<UserDal> {
every { insert(any()) } returnsArgument 0
}
Then, I'm trying to test it like this:
@Test
fun test() {
userService.registerUser(userJohn)
verify(dal).insert(check {
assertEquals(it.firstName, "John")
})
}
This throws an exception:
org.mockito.exceptions.misusing.NotAMockException:
Argument passed to verify() is of type UserDal and is not a mock!
Make sure you place the parenthesis correctly!
I don't understand how it's saying that the UserDal
is not a mock, when it clearly is! What is wrong with this code? How can I verify the argument fields?
Mockito and MockK are two different, incompatible mocking frameworks. You cannot use the Mockito API to stub or verify mocks created by MockK. The reverse is true, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With