/** * Verify all classes and mock objects known by PowerMock. This includes all * classes that are prepared for test using the {@link PrepareForTest} or * {@link PrepareOnlyThisForTest} annotations and all classes that have had * their static initializers removed by using the * {@link SuppressStaticInitializationFor} annotation. It also includes all * mock instances created by PowerMock such as those created or used by * {@link #createMock(Class, Method...)}, * {@link #mockStatic(Class, Method...)}, * {@link #expectNew(Class, Object...)}, * {@link #createPartialMock(Class, String...)} etc. * <p> * Note that all <tt>additionalMocks</tt> passed to the * {@link #replayAll(Object...)} method are also verified here * automatically. * */ public static synchronized void verifyAll() { for (Object classToReplayOrVerify : MockRepository.getObjectsToAutomaticallyReplayAndVerify()) { verify(classToReplayOrVerify); } }
/** * Reset all classes and mock objects known by PowerMock. This includes all * classes that are prepared for test using the {@link PrepareForTest} or * {@link PrepareOnlyThisForTest} annotations and all classes that have had * their static initializers removed by using the * {@link SuppressStaticInitializationFor} annotation. It also includes all * mock instances created by PowerMock such as those created or used by * {@link #createMock(Class, Method...)}, * {@link #mockStatic(Class, Method...)}, * {@link #expectNew(Class, Object...)}, * {@link #createPartialMock(Class, String...)} etc. * <p> * To make it easy to pass in additional mocks <i>not</i> created by the * PowerMock API you can optionally specify them as <tt>additionalMocks</tt> * . These are typically those mock objects you have created using pure * EasyMock or EasyMock class extensions. No additional mocks needs to be * specified if you're only using PowerMock API methods. * * @param additionalMocks * Mocks not created by the PowerMock API. These are typically * those mock objects you have created using pure EasyMock or * EasyMock class extensions. */ public static synchronized void resetAll(Object... additionalMocks) { MockRepository.addObjectsToAutomaticallyReplayAndVerify(additionalMocks); for (Object classToReplayOrVerify : MockRepository.getObjectsToAutomaticallyReplayAndVerify()) { reset(classToReplayOrVerify); } }
MockRepository.addObjectsToAutomaticallyReplayAndVerify(additionalMocks); for (Object classToReplayOrVerify : MockRepository.getObjectsToAutomaticallyReplayAndVerify()) { replay(classToReplayOrVerify);