Class TestOutputDecorator

java.lang.Object
org.junit.runner.notification.RunListener
uk.ac.ebi.utils.test.junit.TestOutputDecorator
All Implemented Interfaces:
org.junit.rules.TestRule

public class TestOutputDecorator extends org.junit.runner.notification.RunListener implements org.junit.rules.TestRule
# An output decorator for JUnit Logs a nice header with the test name before the test and a similar trailer afterward. This can be used in two ways. One is as a TestRule, pretty much the same way you would use ExternalResource. Another option is to add this listener to your runner of choice in order to be invoked automatically for all the tests run via that runner. For instance, see [here](http://maven.apache.org/plugins/maven-surefire-plugin/examples/junit.html#Using_custom_listeners_and_reporters) for what concerns Maven/Surefire. The JUtils's POM is itself another example of that. **WARNING**: this uses SLF4J, you need to enable the INFO level to see anything.
date
Jan 27, 2012
Author:
brandizi
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.junit.runner.notification.RunListener

    org.junit.runner.notification.RunListener.ThreadSafe
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
    You can use this class either as a listener, or a Rule, so we have this method too, to be called by JUnit in the second case.
    void
    testFinished(org.junit.runner.Description description)
     
    void
    testStarted(org.junit.runner.Description description)
     

    Methods inherited from class org.junit.runner.notification.RunListener

    testAssumptionFailure, testFailure, testIgnored, testRunFinished, testRunStarted, testSuiteFinished, testSuiteStarted

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TestOutputDecorator

      public TestOutputDecorator()
  • Method Details

    • testStarted

      public void testStarted(org.junit.runner.Description description) throws Exception
      Overrides:
      testStarted in class org.junit.runner.notification.RunListener
      Throws:
      Exception
    • testFinished

      public void testFinished(org.junit.runner.Description description) throws Exception
      Overrides:
      testFinished in class org.junit.runner.notification.RunListener
      Throws:
      Exception
    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      You can use this class either as a listener, or a Rule, so we have this method too, to be called by JUnit in the second case.
      Specified by:
      apply in interface org.junit.rules.TestRule