org.unitils
Class UnitilsJUnit3

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.unitils.UnitilsJUnit3
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
UnitilsJUnit3TestBase

public abstract class UnitilsJUnit3
extends junit.framework.TestCase

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
UnitilsJUnit3()
          Creates a test without a name.
UnitilsJUnit3(String name)
          Creates a test with the given name.
 
Method Summary
protected  Method getCurrentTestMethod()
          Gets the method that has the same name as the current test.
protected  TestListener getTestListener()
           
protected  Unitils getUnitils()
          This will return the default singleton instance by calling Unitils.getInstance().
 void runBare()
          Overriden JUnit3 method to be able to call TestListener.beforeTestSetUp(java.lang.Object, java.lang.reflect.Method) and TestListener.afterTestTearDown(java.lang.Object, java.lang.reflect.Method).
protected  void runTest()
          Overriden JUnit3 method 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).
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnitilsJUnit3

public UnitilsJUnit3()
Creates a test without a name. Be sure to call TestCase.setName(java.lang.String) afterwards.


UnitilsJUnit3

public UnitilsJUnit3(String name)
Creates a test with the given name. The name should be the name of the test method.

Parameters:
name - the name of the test method
Method Detail

runBare

public void runBare()
             throws Throwable
Overriden JUnit3 method to be able to call TestListener.beforeTestSetUp(java.lang.Object, java.lang.reflect.Method) and TestListener.afterTestTearDown(java.lang.Object, java.lang.reflect.Method).

Overrides:
runBare in class junit.framework.TestCase
Throws:
Throwable - If an error occurs during the test

runTest

protected void runTest()
                throws Throwable
Overriden JUnit3 method 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).

Overrides:
runTest in class junit.framework.TestCase
Throws:
Throwable - If an error occurs during the test

getUnitils

protected Unitils getUnitils()
This will return the default singleton instance by calling Unitils.getInstance().

You can override this method to let it create and set your own singleton instance. For example, you can let it create an instance of your own Unitils subclass and set it by using Unitils.setInstance(org.unitils.core.Unitils).

Returns:
the unitils core instance, not null

getCurrentTestMethod

protected Method getCurrentTestMethod()
Gets the method that has the same name as the current test.

Returns:
the method, not null
Throws:
UnitilsException - if the method could not be found

getTestListener

protected TestListener getTestListener()
Returns:
The unitils test listener


Copyright © 2011. All Rights Reserved.