spat1978 / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Verify times not working correctly after consecutive thenThrow stubs #466

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
using Mockito 1.9.5 on RHEL 5 (64 bit), mockClass is not a Final class

when(mockClass.doSomething(anyString())
                .thenThrow(new RuntimeException())
                .thenThrow(new RuntimeException())
                .thenThrow(new RuntimeException());

verify(mockClass, times(400)).doSomething(anyString());

the verify statement is incorrectly passing. The call to doSomething() is made 
only 3 times and I verified this with debugger.

On the other hand
when(mockClass.doSomething(anyString())
                .thenThrow(new RuntimeException())
                .thenThrow(new RuntimeException())
                .thenReturn("someValue");

verify(mockClass, times(400)).doSomething(anyString());

correctly fails reporting that the call was made just 3 times but expected was 
400.

Original issue reported on code.google.com by usmani.k...@gmail.com on 31 Dec 2013 at 4:35