org.unitils
Class TracingTestListener

java.lang.Object
  extended by org.unitils.core.TestListener
      extended by org.unitils.TracingTestListener

public class TracingTestListener
extends TestListener

Test listener that records all method invocations.

Author:
Tim Ducheyne, Filip Neven

Nested Class Summary
static class TracingTestListener.Call
           
static interface TracingTestListener.Invocation
           
static class TracingTestListener.InvocationSource
           
static class TracingTestListener.ListenerInvocation
           
static class TracingTestListener.TestFramework
           
static class TracingTestListener.TestInvocation
           
 
Constructor Summary
TracingTestListener()
           
 
Method Summary
 void afterCreateTestObject(Object testObject)
          Invoked before any of the test in a test class are run.
 void afterTestMethod(Object testObject, Method testMethod, Throwable throwable)
          Invoked after the test run but before the test tear down (e.g.
 void afterTestTearDown(Object testObject, Method testMethod)
          Invoked after the test tear down (eg @After).
 void beforeTestClass(Class<?> testClass)
          Invoked before the generic class setup (e.g.
 void beforeTestMethod(Object testObject, Method testMethod)
          Invoked before the test but after the test setup (eg @Before) is run.
 void beforeTestSetUp(Object testObject, Method testMethod)
          Invoked before the test setup (eg @Before) is run.
 void expectExceptionInMethod(TracingTestListener.Invocation exceptionMethod, boolean throwAssertionFailedError)
           
 List<TracingTestListener.Call> getCallList()
           
 String getCallListAsString()
           
 Throwable getCurrentThrowable()
           
 void registerListenerInvocation(TracingTestListener.ListenerInvocation listenerInvocation, Class<?> testClass, Object test, Method testMethod, Throwable throwable)
           
 void registerTestInvocation(TracingTestListener.TestInvocation invocation, Class<?> testClass, String methodName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TracingTestListener

public TracingTestListener()
Method Detail

getCallList

public List<TracingTestListener.Call> getCallList()

getCallListAsString

public String getCallListAsString()

expectExceptionInMethod

public void expectExceptionInMethod(TracingTestListener.Invocation exceptionMethod,
                                    boolean throwAssertionFailedError)

registerTestInvocation

public void registerTestInvocation(TracingTestListener.TestInvocation invocation,
                                   Class<?> testClass,
                                   String methodName)

registerListenerInvocation

public void registerListenerInvocation(TracingTestListener.ListenerInvocation listenerInvocation,
                                       Class<?> testClass,
                                       Object test,
                                       Method testMethod,
                                       Throwable throwable)

beforeTestClass

public void beforeTestClass(Class<?> testClass)
Description copied from class: TestListener
Invoked before the generic class setup (e.g. @BeforeClass) is performed.

Overrides:
beforeTestClass in class TestListener
Parameters:
testClass - The class whose test methods are about to be executed, not null

afterCreateTestObject

public void afterCreateTestObject(Object testObject)
Description copied from class: TestListener
Invoked before any of the test in a test class are run. This can be overridden to for example add test-class initialization.

Overrides:
afterCreateTestObject in class TestListener
Parameters:
testObject - The test class, not null

beforeTestSetUp

public void beforeTestSetUp(Object testObject,
                            Method testMethod)
Description copied from class: TestListener
Invoked before the test setup (eg @Before) is run. This can be overridden to for example initialize the test-fixture.

Overrides:
beforeTestSetUp in class TestListener
Parameters:
testObject - The test instance, not null
testMethod - The test method, not null

beforeTestMethod

public void beforeTestMethod(Object testObject,
                             Method testMethod)
Description copied from class: TestListener
Invoked before the test but after the test setup (eg @Before) is run. This can be overridden to for example further initialize the test-fixture using values that were set during the test setup.

Overrides:
beforeTestMethod in class TestListener
Parameters:
testObject - The test instance, not null
testMethod - The test method, not null

afterTestMethod

public void afterTestMethod(Object testObject,
                            Method testMethod,
                            Throwable throwable)
Description copied from class: TestListener
Invoked after the test run but before the test tear down (e.g. @After). This can be overridden to for example add assertions for testing the result of the test. It the before method or the test raised an exception, this exception will be passed to the method.

Overrides:
afterTestMethod in class TestListener
Parameters:
testObject - The test instance, not null
testMethod - The test method, not null
throwable - The throwable thrown during the test or beforeTestMethod, null if none was thrown

afterTestTearDown

public void afterTestTearDown(Object testObject,
                              Method testMethod)
Description copied from class: TestListener
Invoked after the test tear down (eg @After). This can be overridden to for example perform extra cleanup after the test.

Overrides:
afterTestTearDown in class TestListener
Parameters:
testObject - The test instance, not null
testMethod - The test method, not null

getCurrentThrowable

public Throwable getCurrentThrowable()


Copyright © 2011. All Rights Reserved.