Verifying argument values with Mockito
Sometimes it is necessary to verify that a mock object is called with the right argument.
We can do this with org.mockito.ArgumentCaptor like this:
ArgumentCaptor<SteeringWheel> wheelArgument = ArgumentCaptor.forClass(SteeringWheel.class); verify(carMock).turn(wheelArgument.capture()); assertEquals(Direction.LEFT, wheelArgument.getDirection();
Leave a comment