Package org.junit.runner.manipulation
Class Filter
java.lang.Object
org.junit.runner.manipulation.Filter
- Direct Known Subclasses:
Categories.CategoryFilter
The 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, extend
Filter and apply an instance of
your filter to the Request before running it (see
JUnitCore.run(Request). Alternatively, apply a Filter to
a Runner before running tests (for example, in conjunction with
RunWith.- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoke with aRunnerto cause all tests it intends to run to first be checked with the filter.abstract Stringdescribe()Returns a textual description of this FilterReturns 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 Details
-
ALL
A nullFilterthat passes all tests through.
-
-
Constructor Details
-
Filter
public Filter()
-
-
Method Details
-
matchMethodDescription
Returns aFilterthat only runs the single method described bydesiredDescription -
shouldRun
- Parameters:
description- the description of the test to be run- Returns:
trueif the test should be run
-
describe
Returns a textual description of this Filter- Returns:
- a textual description of this Filter
-
apply
Invoke 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
-
intersect
Returns a new Filter that accepts the intersection of the tests accepted by this Filter andsecond
-