Search in sources :

Example 1 with PowerMockJUnit4LegacyTestIntrospector

use of org.powermock.modules.junit4.legacy.internal.impl.testcaseworkaround.PowerMockJUnit4LegacyTestIntrospector in project powermock by powermock.

the class PowerMockJUnit4LegacyRunnerDelegateImpl method run.

@Override
public void run(final RunNotifier notifier) {
    BeforeAndAfterRunner runner = new BeforeAndAfterRunner(getTestClass(), BeforeClass.class, AfterClass.class, null) {

        @Override
        protected void runUnprotected() {
            fEnclosedRunner.run(notifier);
        }

        @Override
        protected void addFailure(Throwable targetException) {
            notifier.fireTestFailure(new Failure(getDescription(), targetException));
        }
    };
    Whitebox.setInternalState(runner, "fTestIntrospector", new PowerMockJUnit4LegacyTestIntrospector(getTestClass()), BeforeAndAfterRunner.class);
    // Initialize mock policies for each test
    final ClassLoader classLoader = this.getClass().getClassLoader();
    new MockPolicyInitializerImpl(getTestClass()).initialize(classLoader);
    Thread.currentThread().setContextClassLoader(classLoader);
    runner.runProtected();
}
Also used : BeforeAndAfterRunner(org.junit.internal.runners.BeforeAndAfterRunner) PowerMockJUnit4LegacyTestIntrospector(org.powermock.modules.junit4.legacy.internal.impl.testcaseworkaround.PowerMockJUnit4LegacyTestIntrospector) MockPolicyInitializerImpl(org.powermock.tests.utils.impl.MockPolicyInitializerImpl) Failure(org.junit.runner.notification.Failure)

Aggregations

BeforeAndAfterRunner (org.junit.internal.runners.BeforeAndAfterRunner)1 Failure (org.junit.runner.notification.Failure)1 PowerMockJUnit4LegacyTestIntrospector (org.powermock.modules.junit4.legacy.internal.impl.testcaseworkaround.PowerMockJUnit4LegacyTestIntrospector)1 MockPolicyInitializerImpl (org.powermock.tests.utils.impl.MockPolicyInitializerImpl)1