Carlos Tasada
11/21/2023, 10:52 AMval publisher = mockk<CommandPublisher>(relaxed = true)
val something = Something(publisher)
val request = Request(field = "a")
something.doSomething(request)
verify {
publisher.publish(any())
}
This works fine. But I want to confirm that the published object is the one I expect
verify {
publisher.publish(Event(request))
}
Where Event(request)
maps some values to the published object.
This check fails, because "arguments are not matching" when looking, the issue seems that verify
is trying to compare by instance, but the expected instance is different. I want to compare by content. I saw that I could use cmpEq
but I cannot find how to use it.
Can someone provide an example of verify
and cmpEq
?
Thanks a lot for your helpMattia Tommasone
11/21/2023, 10:56 AMverify {
publisher.publish(match {
it.request.field == "a"
})
}
Does this make sense to you?Carlos Tasada
11/21/2023, 11:36 AM