Package org.junit.rules
Class TestWatchman
java.lang.Object
org.junit.rules.TestWatchman
- All Implemented Interfaces:
MethodRule
Deprecated.
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() {
}
}
- Since:
- 4.7
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(Statement base, FrameworkMethod method, Object target) Deprecated.Modifies the method-runningStatementto implement an additional test-running rule.voidfailed(Throwable e, FrameworkMethod method) Deprecated.Invoked when a test method failsvoidfinished(FrameworkMethod method) Deprecated.Invoked when a test method finishes (whether passing or failing)voidstarting(FrameworkMethod method) Deprecated.Invoked when a test method is about to startvoidsucceeded(FrameworkMethod method) Deprecated.Invoked when a test method succeeds
-
Constructor Details
-
TestWatchman
public TestWatchman()Deprecated.
-
-
Method Details
-
apply
Deprecated.Description copied from interface:MethodRuleModifies the method-runningStatementto implement an additional test-running rule.- Specified by:
applyin interfaceMethodRule- Parameters:
base- TheStatementto be modifiedmethod- The method to be runtarget- The object on which the method will be run.- Returns:
- a new statement, which may be the same as
base, a wrapper aroundbase, or a completely new Statement.
-
succeeded
Deprecated.Invoked when a test method succeeds -
failed
Deprecated.Invoked when a test method fails -
starting
Deprecated.Invoked when a test method is about to start -
finished
Deprecated.Invoked when a test method finishes (whether passing or failing)
-
TestWatcher(which implementsTestRule) instead.