Class Index

A B C D E F I J M N P R S T V

A

ActiveTestSuite A TestSuite for active Tests. 
After

If you allocate external resources in a Before method you need to release them after the test runs. 

AfterClass

If you allocate expensive external resources in a BeforeClass method you need to release them after all the tests in the class have run. 

AllDefaultPossibilitiesBuilder  
AllMembersSupplier Supplies Theory parameters based on all public members of the target class. 
AllTests Runner for use with JUnit 3.8.x-style AllTests classes (those that only implement a static suite() method). 
AnnotatedBuilder  
ArrayComparisonFailure Thrown when two array elements differ 
Assert A set of assert methods. 
Assert A set of assertion methods useful for writing tests. 
AssertionFailedError Thrown when an assertion failed. 
Assignments A potentially incomplete list of value assignments for a method's formal parameters  
Assume A set of methods useful for stating assumptions about the conditions in which a test is meaningful. 
AssumptionViolatedException  

B

BaseTestRunner Base class for all test runners. 
Before

When writing tests, it is common to find that several tests need similar objects created before they can run. 

BeforeClass

Sometimes several tests need to share computationally expensive setup (like logging into a database). 

BlockJUnit4ClassRunner Implements the JUnit 4 standard test case class model, as defined by the annotations in the org.junit package. 

C

Categories From a given set of test classes, runs only the classes and methods that are annotated with either the category given with the @IncludeCategory annotation, or a subtype of that category. 
Categories.CategoryFilter  
Categories.ExcludeCategory  
Categories.IncludeCategory  
Category Marks a test class or test method as belonging to one or more categories of tests. 
ClassRequest  
ClassRoadie This class is deprecated. Included for backwards compatibility with JUnit 4.4. Will be removed in the next release. Please use BlockJUnit4ClassRunner in place of JUnit4ClassRunner.  
CombinableMatcher<T>  
ComparisonCompactor  
ComparisonCriteria Defines criteria for finding two items "equal enough". 
ComparisonFailure Thrown when an assert equals for Strings failed. 
ComparisonFailure Thrown when an assertEquals(String, String) fails. 
Computer Represents a strategy for computing runners and suites. 
CouldNotReadCoreException Thrown when Max cannot read the MaxCore serialization  

D

DataPoint  
DataPoints  
Describable Represents an object that can describe itself  
Description

A Description describes a test which is to be run or has been run. 

E

Each  
EachTestNotifier  
Enclosed If you put tests in inner classes, Ant, for example, won't find them. 
ErrorCollector The ErrorCollector rule allows execution of a test to continue after the first problem is found (for example, to collect _all_ the incorrect rows in a table, and report them all at once):
 public static class UsesErrorCollectorTwice {
 	@Rule
 	public ErrorCollector collector= new ErrorCollector();
 
 	@Test
 	public void example() {
 		collector.addError(new Throwable("first thing went wrong"));
 		collector.addError(new Throwable("second thing went wrong"));
 		collector.checkThat(getResult(), not(containsString("ERROR!")));
 		// all lines will run, and then a combined failure logged at the end. 
ErrorReportingRunner  
ExactComparisonCriteria  
ExpectedException The ExpectedException Rule allows in-test specification of expected exception types and messages:
 // These tests all pass. 
ExpectException  
ExternalResource A base class for Rules (like TemporaryFolder) that set up an external resource before a test (a file, socket, server, database connection, etc.), and guarantee to tear it down afterward:
 public static class UsesExternalResource {
 	Server myServer= new Server();
 
 	@Rule
 	public ExternalResource resource= new ExternalResource() {
 		@Override
 		protected void before() throws Throwable {
 			myServer.connect();
 		};
 
 		@Override
 		protected void after() {
 			myServer.disconnect();
 		};
 	};
 
 	@Test
 	public void testFoo() {
 		new Client().run(myServer);
 	}
 }
 
 

F

Fail  
FailOnTimeout  
Failure A Failure holds a description of the failed test and the exception that was thrown while running it. 
Filter The canonical case of filtering is when you want to run a single test method in a class. 
Filterable Runners that allow filtering should implement this interface. 
FilterRequest A filtered Request
FrameworkField Represents a field on a test class (currently used only for Rules in BlockJUnit4ClassRunner, but custom runners can make other uses)  
FrameworkMethod Represents a method on a test class to be invoked at the appropriate point in test execution. 

I

Ignore

Sometimes you want to temporarily disable a test or a group of tests. 

IgnoredBuilder  
IgnoredClassRunner  
InexactComparisonCriteria  
InitializationError  
InitializationError Represents one or more problems encountered while initializing a Runner  
InvokeMethod  
IsCollectionContaining<T>  

J

JUnit38ClassRunner  
JUnit3Builder  
JUnit4 Aliases the current default JUnit 4 class runner, for future-proofing. 
JUnit4Builder  
JUnit4ClassRunner This class is deprecated. Included for backwards compatibility with JUnit 4.4. Will be removed in the next release. Please use BlockJUnit4ClassRunner in place of JUnit4ClassRunner. This may disappear as soon as 1 April 2009  
JUnit4TestAdapter  
JUnit4TestAdapterCache  
JUnit4TestCaseFacade  
JUnitCore JUnitCore is a facade for running tests. 
JUnitMatchers Convenience import class: these are useful matchers for use with the assertThat method, but they are not currently included in the basic CoreMatchers class from hamcrest. 
JUnitSystem  

M

MaxCore A replacement for JUnitCore, which keeps track of runtime and failure history, and reorders tests to maximize the chances that a failing test occurs early in the test run. 
MaxHistory Stores a subset of the history of each test:
  • Last failure timestamp
  • Duration of last execution
 
MethodRoadie This class is deprecated. Included for backwards compatibility with JUnit 4.4. Will be removed in the next release. Please use BlockJUnit4ClassRunner in place of JUnit4ClassRunner.  
MethodRule A MethodRule is an alteration in how a test method is run and reported. 
MethodValidator This class is deprecated. Included for backwards compatibility with JUnit 4.4. Will be removed in the next release. Please use BlockJUnit4ClassRunner in place of JUnit4ClassRunner.  
MultipleFailureException  

N

NoTestsRemainException Thrown when a filter removes all tests from a runner. 
NullBuilder  

P

ParallelComputer  
Parameterized

The custom runner Parameterized implements parameterized tests. 

Parameterized.Parameters Annotation for a method which provides parameters to be injected into the test class constructor by Parameterized  
ParameterizedAssertionError  
ParameterSignature  
ParametersSuppliedBy  
ParameterSupplier  
ParentRunner<T> Provides most of the functionality specific to a Runner that implements a "parent node" in the test tree, with children defined by objects of some data type T
PotentialAssignment  
PotentialAssignment.CouldNotGenerateValueException  
PrintableResult A test result that prints nicely in error messages. 
Protectable A Protectable can be run and can throw a Throwable. 

R

RealSystem  
ReflectiveCallable When invoked, throws the exception from the reflected method, rather than wrapping it in an InvocationTargetException. 
RepeatedTest A Decorator that runs a test repeatedly. 
Request

A Request is an abstract description of tests to be run. 

Result A Result collects and summarizes information from running multiple tests. 
ResultMatchers Matchers on a PrintableResult, to enable JUnit self-tests. 
ResultPrinter  
Rule Annotates fields that contain rules. 
RunAfters  
RunBefores  
RunListener

If you need to respond to the events during a test run, extend RunListener and override the appropriate methods. 

Runner A Runner runs tests and notifies a RunNotifier of significant events as it does so. 
RunnerBuilder A RunnerBuilder is a strategy for constructing runners for classes. 
RunnerScheduler Represents a strategy for scheduling when individual test methods should be run (in serial or parallel) WARNING: still experimental, may go away. 
RunNotifier If you write custom runners, you may need to notify JUnit of your progress running tests. 
RunWith When a class is annotated with @RunWith or extends a class annotated with @RunWith, JUnit will invoke the class it references to run the tests in that class instead of the runner built into JUnit. 

S

Sortable Interface for runners that allow sorting of tests. 
Sorter A Sorter orders tests. 
SortingRequest  
Statement Represents one or more actions to be taken at runtime in the course of running a JUnit test suite. 
StoppedByUserException Thrown when a user has requested that the test run stop. 
StringContains Tests if the argument is a string that contains a substring. 
SubstringMatcher  
Suite Using Suite as a runner allows you to manually build a suite containing tests from many classes. 
Suite.SuiteClasses The SuiteClasses annotation specifies the classes to be run when a class annotated with @RunWith(Suite.class) is run. 
SuiteMethod Runner for use with JUnit 3.8.x-style AllTests classes (those that only implement a static suite() method). 
SuiteMethodBuilder  

T

TemporaryFolder The TemporaryFolder Rule allows creation of files and folders that are guaranteed to be deleted when the test method finishes (whether it passes or fails):
 public static class HasTempFolder {
 	@Rule
 	public TemporaryFolder folder= new TemporaryFolder();
 
 	@Test
 	public void testUsingTempFolder() throws IOException {
 		File createdFile= folder.newFile("myfile.txt");
 		File createdFolder= folder.newFolder("subfolder");
 		// ... 
Test A Test can be run and collect its results. 
Test

The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case. 

Test.None Default empty exception  
TestCase A test case defines the fixture to run multiple tests. 
TestClass This class is deprecated. Included for backwards compatibility with JUnit 4.4. Will be removed in the next release. Please use BlockJUnit4ClassRunner in place of JUnit4ClassRunner.  
TestClass Wraps a class to be run, providing method validation and annotation searching  
TestDecorator A Decorator for Tests. 
TestedOn  
TestedOnSupplier  
TestFailure A TestFailure collects a failed test together with the caught exception. 
TestListener A Listener for test progress  
TestMethod This class is deprecated. Included for backwards compatibility with JUnit 4.4. Will be removed in the next release. Please use BlockJUnit4ClassRunner in place of JUnit4ClassRunner.  
TestName The TestName Rule makes the current test name available inside test methods:
 public class TestNameTest {
 	@Rule
 	public TestName name= new TestName();
 
 	@Test
 	public void testA() {
 		assertEquals("testA", name.getMethodName());
 	}
 
 	@Test
 	public void testB() {
 		assertEquals("testB", name.getMethodName());
 	}
 }
 
 
TestResult A TestResult collects the results of executing a test case. 
TestRunListener A listener interface for observing the execution of a test run. 
TestRunner A command line based tool to run tests. 
TestSetup A Decorator to set up and tear down additional fixture state. 
TestSuite

A TestSuite is a Composite of Tests. 

TestWatchman TestWatchman is a base class for Rules that take note of the testing action, without modifying it. 
TextListener  
Theories  
Theories.TheoryAnchor  
Theory  
Timeout The Timeout Rule applies the same timeout to all test methods in a class:
 public static class HasGlobalTimeout {
 	public static String log;
 
 	@Rule
 	public MethodRule globalTimeout= new Timeout(20);
 
 	@Test
 	public void testInfiniteLoop1() {
 		log+= "ran1";
 		for (;;) {
 		}
 	}
 
 	@Test
 	public void testInfiniteLoop2() {
 		log+= "ran2";
 		for (;;) {
 		}
 	}
 }
 
 
TypeSafeMatcher<T> Convenient base class for Matchers that require a non-null value of a specific type. 

V

Verifier Verifier is a base class for Rules like ErrorCollector, which can turn otherwise passing test methods into failing tests if a verification check is failed
     public static class ErrorLogVerifier() {
        private ErrorLog errorLog = new ErrorLog();
     
        @Rule
        public MethodRule verifier = new Verifier() {
           @Override public void verify() {
              assertTrue(errorLog.isEmpty());
           }
        }
        
        @Test public void testThatMightWriteErrorLog() {
           // ... 
Version This class defines the current version of JUnit