The situation
I have an interface of a Tracker
which has this method:
fun trackEvent(event: String, args: Bundle? = null)
I want to verify, that this method is called with a specific event
.
Internally object that being tested call this method with Bundle
object.
All the events are specified as
companion object {
const val EVENT = "EVENT"
}
The problem
The test fails with this verification:
Mockito.verify(tracker).trackEvent(Tracker.EVENT)
with message:
Argument(s) are different! Wanted: tracker.trackEvent("EVENT", null); ...
Actual invocation has different arguments: tracker.trackEvent("EVENT", null); ...
There are many solutions, which are using
Mockito.eq()
, Mockito.refEq()
, ArgumentMatchers
, Captures
, etc. None of them worked for me, giving the same or NullPointerException