程序包 org.junit.rules
类 TestWatchman
- java.lang.Object
- org.junit.rules.TestWatchman
- 所有已实现的接口:
MethodRule
@Deprecated public class TestWatchman extends Object implements MethodRule
已过时。UseTestWatcher
(which implementsTestRule
) instead.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() { } }
- 从以下版本开始:
- 4.7
构造器概要
构造器 构造器 说明 TestWatchman()
已过时。
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 Statement
apply(Statement base, FrameworkMethod method, Object target)
已过时。Modifies the method-runningStatement
to implement an additional test-running rule.void
failed(Throwable e, FrameworkMethod method)
已过时。Invoked when a test method failsvoid
finished(FrameworkMethod method)
已过时。Invoked when a test method finishes (whether passing or failing)void
starting(FrameworkMethod method)
已过时。Invoked when a test method is about to startvoid
succeeded(FrameworkMethod method)
已过时。Invoked when a test method succeeds
构造器详细资料
TestWatchman
public TestWatchman()
已过时。
方法详细资料
apply
public Statement apply(Statement base, FrameworkMethod method, Object target)
已过时。从接口复制的说明:MethodRule
Modifies the method-runningStatement
to implement an additional test-running rule.- 指定者:
apply
在接口中MethodRule
- 参数:
base
- TheStatement
to be modifiedmethod
- The method to be runtarget
- The object on which the method will be run.- 返回:
- a new statement, which may be the same as
base
, a wrapper aroundbase
, or a completely new Statement.
succeeded
public void succeeded(FrameworkMethod method)
已过时。Invoked when a test method succeeds
failed
public void failed(Throwable e, FrameworkMethod method)
已过时。Invoked when a test method fails
starting
public void starting(FrameworkMethod method)
已过时。Invoked when a test method is about to start
finished
public void finished(FrameworkMethod method)
已过时。Invoked when a test method finishes (whether passing or failing)