Mockito gives UnfinishedVerificationException when it seems OK
问题 Mockito appears to be throwing an UnfinishedVerificationException when I think I've done everything correctly. Here's my partial test case: HttpServletRequest req = mock(HttpServletRequest.class); when(req.getHeader("Authorization")).thenReturn("foo"); HttpServletResponse res = mock(HttpServletResponse.class); classUnderTest.doMethod(req, res); // Use the mock verify(res, never()); verify(req).setAttribute(anyString(), anyObject()); And here's the partial class and method: class