java.lang.Object | |
↳ | org.junit.rules.TestWatchman |
Known Direct Subclasses |
TestWatchman is a base class for Rules that take note of the testing action, without modifying it. For example, this class will keep a log of each passing and failing test:
public static class WatchmanTest { private static String watchedLog; @Rule public MethodRule watchman= new TestWatchman() { @Override public void failed(Throwable e, FrameworkMethod method) { watchedLog+= method.getName() + " " + e.getClass().getSimpleName() + "\n"; } @Override public void succeeded(FrameworkMethod method) { watchedLog+= method.getName() + " " + "success!\n"; } }; @Test public void fails() { fail(); } @Test public void succeeds() { } }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Modifies the method-running
Statement to implement an additional
test-running rule. | |||||||||||
Invoked when a test method fails
| |||||||||||
Invoked when a test method finishes (whether passing or failing)
| |||||||||||
Invoked when a test method is about to start
| |||||||||||
Invoked when a test method succeeds
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.junit.rules.MethodRule
|
Modifies the method-running Statement
to implement an additional
test-running rule.
base | The Statement to be modified |
---|---|
method | The method to be run |
target | The object on with the method will be run. |
base
,
a wrapper around base
, or a completely new Statement.
Invoked when a test method finishes (whether passing or failing)