I’m using Mockito to mock a class that has a method that looks something like this:
setFoo(int offset, float[] floats)
I want to be able verify that the values in the array (floats) are equal (within a given tolerance) to values in an array of expected values.
The catch is that I want to check the contents of floats starting at the position specified by offset. For the purposes of the test I don’t know/care what the offset is as long as it points at the values I’m expecting. I also don’t care what the rest of the array contains. I only care about the values starting at the supplied offset.
How do I do this?
While a partial mock isn’t a bad idea, you might find your code easier to follow if you use an ArgumentCaptor instead to get the values after the fact. It’s a special argument matcher that keeps track of the value it matches.