Looking at the code below, I only expect the call to getSand()
to happen once, but the test is failing with four calls to it. Where are these calls happening? I wan
It's counting your setup as invocations since deeps stubs is not supported in the verification API, and complains on the second call which is:
when(mockSandBox.getSand().doB()).thenReturn(1);
I would skip using RETURNS_DEEP_STUBS and just use another mock:
...
@Mock
SandBox mockSandBox;
@Mock
Sand sand;
@Test
public void should(){
when(mockSandBox.getSand()).thenReturn(sand);
when(sand.doA()).thenReturn(1);
when(sand.doB()).thenReturn(1);
when(sand.doC()).thenReturn(1);
...