Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.junit.rules
Class TestWatchman

    java.lang.Object
      org.junit.rules.TestWatchman

All Implemented Interfaces:
  MethodRule

Direct Known Subclasses:
  TestName

    public class TestWatchman

extends Object
implements MethodRule

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() {
            }
     }

Constructor Summary
`TestWatchman()`

Method Summary
`Statement` | `apply(Statement base, FrameworkMethod method, Object target)` Modifies the method-running `Statement` to implement an additional test-running rule.
`void` | `failed(Throwable e, FrameworkMethod method)` Invoked when a test method fails
`void` | `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 start
`void` | `succeeded(FrameworkMethod method)` Invoked when a test method succeeds

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TestWatchman

    public TestWatchman()

Method Detail

### apply

    public Statement apply(Statement base,
                           FrameworkMethod method,
                           Object target)

  Description copied from interface: `MethodRule`
  Modifies the method-running `Statement` to implement an additional test-running rule.

  Specified by:
    `apply` in interface `MethodRule`
  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.

### succeeded

    public void succeeded(FrameworkMethod method)

  Invoked when a test method succeeds

  Parameters:
    `method` -

### failed

    public void failed(Throwable e,
                       FrameworkMethod method)

  Invoked when a test method fails

  Parameters:
    `e` -
    `method` -

### starting

    public void starting(FrameworkMethod method)

  Invoked when a test method is about to start

  Parameters:
    `method` -

### finished

    public void finished(FrameworkMethod method)

  Invoked when a test method finishes (whether passing or failing)

  Parameters:
    `method` -

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD