org.test4j.module.core
类 TestListener

java.lang.Object
  继承者 org.test4j.module.core.TestListener
直接已知子类:
InjectModule.InjectTestListener, JMockitModule.JMockitTestListener

public abstract class TestListener
extends Object

Listener for test events. The events must follow following ordering:

The after methods will always when the before counterpart has run (or begun). For example if an exception occurs during the setupMethod method, the teardownMethod method will still be called.

Is implemented as an abstract class with empty methods instead of an interface, since most implementations only need to implement a small subset of the provided callback methods.


构造方法摘要
TestListener()
           
 
方法摘要
 void afterClass(Object testObject)
          Invoked after the test class tear down (eg @AfterClass).
 void afterMethod(Object testObject, Method testMethod)
          Invoked after the test tear down (eg @After).
 void afterRunned(Object testObject, Method testMethod, Throwable testThrowable)
          Invoked after the test run but before the test tear down (e.g.
 void beforeClass(Class testClazz)
          Invoked before any of the test in a test class are run.
 void beforeMethod(Object testObject, Method testMethod)
          Invoked before the test setup (eg @Before) is run.
 void beforeRunning(Object testObject, Method testMethod)
          Invoked before the test but after the test setup (eg @Before) is run.
protected abstract  String getName()
          监听器名称
 String toString()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

TestListener

public TestListener()
方法详细信息

beforeClass

public void beforeClass(Class testClazz)
Invoked before any of the test in a test class are run. This can be overridden to for example add test-class initialization.
Phase
o setupClass (Object testObject)
o beforeMethod (Object testObject, Method testMethod)
o beforeMethodRunning (Object testObject, Method testMethod)
o afterMethodRunned (Object testObject, Method testMethod, Throwable testThrowable)
o afterMethod (Object testObject, Method testMethod)
o teardownClass (Object testObject)

参数:
testObject - The test class, not null

beforeMethod

public void beforeMethod(Object testObject,
                         Method testMethod)
Invoked before the test setup (eg @Before) is run. This can be overridden to for example initialize the test-fixture.
Phase
o setupClass (Object testObject)
o beforeMethod (Object testObject, Method testMethod)
o beforeMethodRunning (Object testObject, Method testMethod)
o afterMethodRunned (Object testObject, Method testMethod, Throwable testThrowable)
o afterMethod (Object testObject, Method testMethod)
o teardownClass (Object testObject)

参数:
testObject - The test instance, not null
testMethod - The test method, not null

beforeRunning

public void beforeRunning(Object testObject,
                          Method testMethod)
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.
Phase
o setupClass (Object testObject)
o beforeMethod (Object testObject, Method testMethod)
o beforeMethodRunning (Object testObject, Method testMethod)
o afterMethodRunned (Object testObject, Method testMethod, Throwable testThrowable)
o afterMethod (Object testObject, Method testMethod)
o teardownClass (Object testObject)

参数:
testObject - The test instance, not null
testMethod - The test method, not null

afterRunned

public void afterRunned(Object testObject,
                        Method testMethod,
                        Throwable testThrowable)
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.
Phase
o setupClass (Object testObject)
o beforeMethod (Object testObject, Method testMethod)
o beforeMethodRunning (Object testObject, Method testMethod)
o afterMethodRunned (Object testObject, Method testMethod, Throwable testThrowable)
o afterMethod (Object testObject, Method testMethod)
o teardownClass (Object testObject)

参数:
testObject - The test instance, not null
testMethod - The test method, not null
testThrowable - The throwable thrown during the test or beforeMethodRunning, null if none was thrown

afterMethod

public void afterMethod(Object testObject,
                        Method testMethod)
Invoked after the test tear down (eg @After). This can be overridden to for example perform extra cleanup after the test.
Phase
o setupClass (Object testObject)
o beforeMethod (Object testObject, Method testMethod)
o beforeMethodRunning (Object testObject, Method testMethod)
o afterMethodRunned (Object testObject, Method testMethod, Throwable testThrowable)
o afterMethod (Object testObject, Method testMethod)
o teardownClass (Object testObject)

参数:
testObject - The test instance, not null
testMethod - The test method, not null

afterClass

public void afterClass(Object testObject)
Invoked after the test class tear down (eg @AfterClass).
Phase
o setupClass (Object testObject)
o beforeMethod (Object testObject, Method testMethod)
o beforeMethodRunning (Object testObject, Method testMethod)
o afterMethodRunned (Object testObject, Method testMethod, Throwable testThrowable)
o afterMethod (Object testObject, Method testMethod)
o teardownClass (Object testObject)

参数:
testObject -
抛出:
Exception

toString

public String toString()
覆盖:
Object 中的 toString

getName

protected abstract String getName()
监听器名称

返回:


Copyright © 2013. All rights reserved.