Mocking behaviour resets after each test with PowerMock
The method PowerMockito.mockStatic(…) invokes MockCreator.mock(…). This method regsiters a Runnable that will be executed after each test : MockRepository.addAfterMethodRunner(new MockitoStateCleaner()); This runnable cleans the internal state of Mockito : private static class MockitoStateCleaner implements Runnable { public void run() { clearMockProgress(); clearConfiguration(); } private void clearMockProgress() { clearThreadLocalIn(ThreadSafeMockingProgress.class); } private void clearConfiguration() { clearThreadLocalIn(GlobalConfiguration.class); } … Read more