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:
- [test4j] setupClass - TestClass1
- [Test] testBeforeClass - TestClass1 (not for JUnit3)
- [test4j] setupMethod - TestClass1
- [Test] testSetUp - TestClass1
- [test4j] beforeMethodRunning - TestClass1 - test1
- [Test] testMethod - TestClass1 - test1
- [test4j] afterMethodRunned - TestClass1 - test1
- [Test] testTearDown - TestClass1
- [test4j] teardownMethod - TestClass1
- [test4j] setupMethod - TestClass1
- [Test] testSetUp - TestClass1
- [test4j] beforeMethodRunning - TestClass1 - test2
- [Test] testMethod - TestClass1 - test2
- [test4j] afterMethodRunned - TestClass1 - test2
- [Test] testTearDown - TestClass1
- [test4j] teardownMethod - TestClass1
- [Test] testAfterClass - TestClass1 (not for JUnit3)
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
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 nulltestMethod - 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 nulltestMethod - 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 nulltestMethod - The test method, not nulltestThrowable - 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 nulltestMethod - 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.