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?