
de.bechte.junit.runners.context.statements.builder.AfterClassStatementBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-hierarchicalcontextrunner Show documentation
Show all versions of junit-hierarchicalcontextrunner Show documentation
This is a runner implementation that supports context hierarchies in JUnit. For more
details please visit: https://github.com/bechte/junit-hierarchicalcontextrunner/wiki
package de.bechte.junit.runners.context.statements.builder;
import org.junit.AfterClass;
import org.junit.internal.runners.statements.RunAfters;
import org.junit.runner.Description;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.junit.runners.model.TestClass;
import java.util.List;
/**
* The {@link AfterClassStatementBuilder} creates a {@link RunAfters} statement that evaluates all {@code @AfterClass}
* annotated methods. If no such method exist, the builder will simply return the provided next {@link Statement}.
*/
public class AfterClassStatementBuilder implements ClassStatementBuilder {
public Statement createStatement(final TestClass testClass, final Statement next,
final Description description, final RunNotifier notifier) {
final List afters = testClass.getAnnotatedMethods(AfterClass.class);
return afters.isEmpty() ? next : new RunAfters(next, afters, null);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy