
de.bechte.junit.runners.context.statements.RunChildren 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;
import de.bechte.junit.runners.context.processing.ChildExecutor;
import de.bechte.junit.runners.context.processing.ChildResolver;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.Statement;
import org.junit.runners.model.TestClass;
import java.util.List;
/**
* The {@link RunChildren} statement takes four arguments:
* {@link TestClass}, {@link ChildExecutor}, {@link List} of children, {@link RunNotifier}
*
* When evaluated, the statement calls {@link ChildExecutor#run(TestClass, Object, RunNotifier)} on each child.
*
* Note: The type of the {@link ChildExecutor} instance must match the type of the {@code List} of children.
*
* @param the type to run
*/
public class RunChildren extends Statement {
private final TestClass testClass;
private final ChildExecutor childExecutor;
private final ChildResolver childResolver;
private final RunNotifier notifier;
public RunChildren(final TestClass testClass, final ChildExecutor childExecutor,
final ChildResolver childResolver, final RunNotifier notifier) {
this.testClass = testClass;
this.childExecutor = childExecutor;
this.childResolver = childResolver;
this.notifier = notifier;
}
@Override
public void evaluate() throws Throwable {
for (final T child : childResolver.getChildren(testClass))
childExecutor.run(testClass, child, notifier);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy