Known Direct Subclasses
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. |
|
Class Overview
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() {
// ...
}
}
Summary
Protected Methods |
void
|
verify()
Override this to add verification logic.
|
Public Constructors
Public Methods
Modifies the method-running Statement
to implement an additional
test-running rule.
Parameters
base
| The Statement to be modified |
method
| The method to be run |
target
| The object on with the method will be run. |
Returns
- a new statement, which may be the same as
base
,
a wrapper around base
, or a completely new Statement.
Protected Methods
protected
void
verify
()
Override this to add verification logic. Overrides should throw an
exception to indicate that verification failed.