org.junit.runner.manipulation

Class Filter


public abstract class Filter
extends java.lang.Object

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.

Field Summary

static Filter
ALL
A null Filter that passes all tests through.

Method Summary

void
apply(Runner runner)
Invoke with a Runner to cause all tests it intends to run to first be checked with the filter.
abstract String
describe()
Returns a textual description of this Filter
abstract boolean
shouldRun(Description description)

Field Details

ALL

public static Filter ALL
A null Filter that passes all tests through.

Method Details

apply

public void apply(Runner runner)
            throws NoTestsRemainException
Invoke with a Runner to cause all tests it intends to run to first be checked with the filter. Only those that pass the filter will be run.
Parameters:
runner - the runner to be filtered by the receiver
Throws:
NoTestsRemainException - if the receiver removes all tests

describe

public abstract String describe()
Returns a textual description of this Filter
Returns:
a textual description of this Filter

shouldRun

public abstract boolean shouldRun(Description description)
Parameters:
description - the description of the test to be run
Returns:
true if the test should be run