org.unitils
Class UnitilsTestNG

java.lang.Object
  extended by org.unitils.UnitilsTestNG
All Implemented Interfaces:
org.testng.IHookable

public abstract class UnitilsTestNG
extends Object
implements org.testng.IHookable

Base test class that will Unitils-enable your test. This base class will make sure that the core unitils test listener methods are invoked in the expected order. See TestListener for more information on the listener invocation order.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
UnitilsTestNG()
           
 
Method Summary
protected  TestListener getTestListener()
           
protected  Unitils getUnitils()
          Returns the default singleton instance of Unitils
 void run(org.testng.IHookCallBack callBack, org.testng.ITestResult testResult)
          Implementation of the hookable interface to be able to call TestListener.beforeTestMethod(java.lang.Object, java.lang.reflect.Method) and TestListener.afterTestMethod(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable).
protected  void throwException(Throwable throwable)
          Throws an unchecked excepton for the given throwable.
protected  void unitilsAfterTestTearDown(Method testMethod)
          Called after all test tear down.
protected  void unitilsBeforeClass()
          Called before a test of a test class is run.
protected  void unitilsBeforeTestSetUp(Method testMethod)
          Called before all test setup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitilsTestNG

public UnitilsTestNG()
Method Detail

unitilsBeforeClass

protected void unitilsBeforeClass()
Called before a test of a test class is run. This is where TestListener.afterCreateTestObject(Object) is called.


unitilsBeforeTestSetUp

protected void unitilsBeforeTestSetUp(Method testMethod)
Called before all test setup. This is where TestListener.beforeTestSetUp(java.lang.Object, java.lang.reflect.Method) is called.

Parameters:
testMethod - The test method, not null

unitilsAfterTestTearDown

protected void unitilsAfterTestTearDown(Method testMethod)
Called after all test tear down. This is where TestListener.afterTestTearDown(java.lang.Object, java.lang.reflect.Method) is called.

NOTE: alwaysRun is enabled to be sure that this method is called even when an exception occurs during unitilsBeforeTestSetUp(java.lang.reflect.Method).

Parameters:
testMethod - The test method, not null

run

public void run(org.testng.IHookCallBack callBack,
                org.testng.ITestResult testResult)
Implementation of the hookable interface to be able to call TestListener.beforeTestMethod(java.lang.Object, java.lang.reflect.Method) and TestListener.afterTestMethod(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable).

Specified by:
run in interface org.testng.IHookable
Parameters:
callBack - the TestNG test callback, not null
testResult - the TestNG test result, not null

throwException

protected void throwException(Throwable throwable)
Throws an unchecked excepton for the given throwable.

Parameters:
throwable - The throwable, not null

getTestListener

protected TestListener getTestListener()
Returns:
The Unitils test listener

getUnitils

protected Unitils getUnitils()
Returns the default singleton instance of Unitils

Returns:
the Unitils instance, not null


Copyright © 2011. All Rights Reserved.