Create a Request
that, when processed, will run all the tests
in a class.
Add Description
as a child of the receiver.
Add a listener to be notified as the tests run.
If you allocate external resources in a
Before
method you need to release them
after the test runs.
If you allocate expensive external resources in a
BeforeClass
method you need to release them
after all the tests in the class have run.
ALL - static field in class org.junit.runner.manipulation.
Filter A null Filter
that passes all tests through.
Runner for use with JUnit 3.8.x-style AllTests classes
(those that only implement a static suite()
method).
Invoke with a
Runner
to cause all tests it intends to run
to first be checked with the filter.
Sorts the test in runner
using comparator
A set of assertion methods useful for writing tests.
Protect constructor since it is a static only class
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
Asserts that two object arrays are equal.
TODO: fix javadoc
Asserts that two object arrays are equal.
Asserts that two doubles or floats are equal to within a positive delta.
Asserts that two objects are equal.
Asserts that two doubles or floats are equal to within a positive delta.
Asserts that two objects are equal.
Asserts that a condition is false.
Asserts that a condition is false.
Asserts that an object isn't null.
Asserts that an object isn't null.
Asserts that two objects do not refer to the same object.
Asserts that two objects do not refer to the same object.
Asserts that an object is null.
Asserts that an object is null.
Asserts that two objects refer to the same object.
Asserts that two objects refer to the same object.
Asserts that a condition is true.
Asserts that a condition is true.
Fails a test with no message.
Fails a test with the given message.
A Failure
holds a description of the failed test and the
exception that was thrown while running it.
Constructs a Failure
with the given description and exception.
The canonical case of filtering is when you want to run a single test method in a class.
Remove tests that don't pass the parameter filter
.
Runners that allow filtering should implement this interface.
Returns a Request that only runs contains tests whose
Description
equals
desiredDescription
Returns a Request that only contains those tests that should run when
filter
is applied
Invoke to tell listeners that an atomic test failed.
Invoke to tell listeners that an atomic test finished.
Invoke to tell listeners that an atomic test was ignored.
Invoke to tell listeners that an atomic test is about to start.
A Request
is an abstract description of tests to be run.
A Result
collects and summarizes information from running multiple
tests.
Run all the tests in classes
.
Run all the tests contained in JUnit 3.8.x test
.
Run the tests for this runner.
Run all the tests contained in request
.
Run the tests contained in classes
.
If you need to respond to the events during a test run, extend RunListener
and override the appropriate methods.
A
Runner
runs tests and notifies a
RunNotifier
of significant events as it does so.
If you write custom runners, you may need to notify JUnit of your progress running tests.
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.
Sorts the tests using sorter
Interface for runners that allow sorting of tests.
Creates a Sorter
that uses comparator
to sort tests
Returns a Request whose Tests can be run in a certain order, defined by
comparator
For example, here is code to run a test suite in alphabetical order:
private static Comparator forward() {
return new Comparator() {
public int compare(Description o1, Description o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
};
}
public static main() {
new JUnitCore().run(Request.aClass(AllTests.class).sortWith(forward()));
}
Thrown when a user has requested that the test run stop.
Returns "..." in place of common prefix and "..." in
place of common suffix between expected and actual.
Using Suite
as a runner allows you to manually
build a suite containing tests from many classes.
The Test
annotation tells JUnit that the public void
method
to which it is attached can be run as a test case.
Called when an atomic test fails.
Called when an atomic test has finished, whether the test succeeds or fails.
Called when a test will not be run, generally because a test method is annotated
with
Ignore
.
Called when all tests have finished
Called before any tests have been run.
Called when an atomic test is about to be started.
Optionally specify timeout
in milliseconds to cause a test method to fail if it
takes longer than that number of milliseconds.