/** * Discards any mocks set up for the specified classes that are currently in effect, for all test * scopes: the current test method (if any), the current test (which starts with the first * "before" method and continues until the last "after" method), the current test class (which * includes all code from the first "before class" method to the last "after class" method), and * the current test suite. * * <p>Notice that if one of the given real classes has a mock class applied at the level of the * test class, calling this method would negate the application of that mock class. JMockit will * automatically restore classes mocked by a test at the end of its execution, as well as all * classes mocked for the test class as a whole (through a "before class" method or an * {@code @UsingMocksAndStubs} annotation) before the first test in the next test class is * executed. * * @param realClasses one or more real classes from production code, which may have mocked methods */ public static void tearDownMocks(Class<?>... realClasses) { Set<Class<?>> classesToRestore = new HashSet<Class<?>>(); Collections.addAll(classesToRestore, realClasses); TestRun.mockFixture().restoreAndRemoveRedefinedClasses(classesToRestore); }