org.junit.experimental.categories.ExcludeCategories Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit Show documentation
Show all versions of junit Show documentation
JUnit is a unit testing framework for Java, created by Erich Gamma and Kent Beck.
package org.junit.experimental.categories;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.experimental.categories.Categories.CategoryFilter;
import org.junit.runner.manipulation.Filter;
/**
* {@link org.junit.runner.FilterFactory} to exclude categories.
*
* The {@link Filter} that is created will filter out tests that are categorized with any of the
* given categories.
*
* Usage from command line:
*
* --filter=org.junit.experimental.categories.ExcludeCategories=pkg.of.Cat1,pkg.of.Cat2
*
*
* Usage from API:
*
* new ExcludeCategories().createFilter(Cat1.class, Cat2.class);
*
*/
public final class ExcludeCategories extends CategoryFilterFactory {
/**
* Creates a {@link Filter} which is only passed by tests that are
* not categorized with any of the specified categories.
*
* @param categories Category classes.
*/
@Override
protected Filter createFilter(List> categories) {
return new ExcludesAny(categories);
}
private static class ExcludesAny extends CategoryFilter {
public ExcludesAny(List> categories) {
this(new HashSet>(categories));
}
public ExcludesAny(Set> categories) {
super(true, null, true, categories);
}
@Override
public String describe() {
return "excludes " + super.describe();
}
}
}