Package org.junit.runner.manipulation
Class Filter
- java.lang.Object
-
- org.junit.runner.manipulation.Filter
-
- Direct Known Subclasses:
Categories.CategoryFilter
public abstract class Filter extends java.lang.ObjectThe canonical case of filtering is when you want to run a single test method in a class. Rather than introduce runner API just for that one case, JUnit provides a general filtering mechanism. If you want to filter the tests to be run, extendFilterand apply an instance of your filter to theRequestbefore running it (seeJUnitCore.run(Request). Alternatively, apply aFilterto aRunnerbefore running tests (for example, in conjunction withRunWith.- Since:
- 4.0
-
-
Constructor Summary
Constructors Constructor Description Filter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidapply(java.lang.Object child)Invoke with aRunnerto cause all tests it intends to run to first be checked with the filter.abstract java.lang.Stringdescribe()Returns a textual description of this FilterFilterintersect(Filter second)Returns a new Filter that accepts the intersection of the tests accepted by this Filter andsecondstatic FiltermatchMethodDescription(Description desiredDescription)Returns aFilterthat only runs the single method described bydesiredDescriptionabstract booleanshouldRun(Description description)
-
-
-
Field Detail
-
ALL
public static final Filter ALL
A nullFilterthat passes all tests through.
-
-
Method Detail
-
matchMethodDescription
public static Filter matchMethodDescription(Description desiredDescription)
Returns aFilterthat only runs the single method described bydesiredDescription
-
shouldRun
public abstract boolean shouldRun(Description description)
- Parameters:
description- the description of the test to be run- Returns:
trueif the test should be run
-
describe
public abstract java.lang.String describe()
Returns a textual description of this Filter- Returns:
- a textual description of this Filter
-
apply
public void apply(java.lang.Object child) throws NoTestsRemainExceptionInvoke with aRunnerto cause all tests it intends to run to first be checked with the filter. Only those that pass the filter will be run.- Parameters:
child- the runner to be filtered by the receiver- Throws:
NoTestsRemainException- if the receiver removes all tests
-
-