
de.bechte.junit.runners.validation.ChildrenCountValidator 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.validation;
import de.bechte.junit.runners.context.processing.ChildResolver;
import de.bechte.junit.runners.context.processing.ContextResolver;
import de.bechte.junit.runners.context.processing.MethodResolver;
import org.junit.runners.model.TestClass;
import java.util.List;
/**
* The {@link ChildrenCountValidator}s validate that the given {@link TestClass} contains at least 1 child. If there
* is no child within the {@link TestClass} an error is reported in the {@link List} of errors.
*/
public enum ChildrenCountValidator implements TestClassValidator {
TEST_METHODS(new MethodResolver(), "No tests found!"),
CONTEXT_HIERARCHIES(new ContextResolver(), "No contexts found!");
private final ChildResolver> childResolver;
private final String errorMessage;
private ChildrenCountValidator(final ChildResolver> childResolver, final String errorMessage) {
this.childResolver = childResolver;
this.errorMessage = errorMessage;
}
public void validate(final TestClass testClass, final List errors) {
if (childResolver.getChildren(testClass).isEmpty())
errors.add(new Exception(errorMessage));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy