InOrder
帮助您做到这一点。
ServiceClassA firstMock = mock(ServiceClassA.class);ServiceClassB secondMock = mock(ServiceClassB.class);Mockito.donothing().when(firstMock).methodOne(); Mockito.donothing().when(secondMock).methodTwo();//create inOrder object passing any mocks that need to be verified in orderInOrder inOrder = inOrder(firstMock, secondMock);//following will make sure that firstMock was called before secondMockinOrder.verify(firstMock).methodOne();inOrder.verify(secondMock).methodTwo();



