All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.bechte.junit.runners.context.statements.RunChildren Maven / Gradle / Ivy

Go to download

This is a runner implementation that supports context hierarchies in JUnit. For more details please visit: https://github.com/bechte/junit-hierarchicalcontextrunner/wiki

There is a newer version: 4.12.2
Show newest version
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