use of org.junit.internal.runners.BeforeAndAfterRunner 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();
}
Aggregations