org.callbackparams.junit3
Class CallbackTestSuite

java.lang.Object
  extended by junit.framework.TestSuite
      extended by org.callbackparams.junit3.CallbackTestSuite
All Implemented Interfaces:
junit.framework.Test

public class CallbackTestSuite
extends junit.framework.TestSuite

TestSuite implementation that could be useful under JUnit-3.8.x when CallbackTestCase cannot be subclassed, such as when it is desired to subclass another third-party TestCase implementation, e.g. MockObjectTestCase in JMock-1.x.

Example usage ...

 public class MyTest extends MockObjectTestCase {

     private CallbackInterface foo;
 
     //
     // ... Test-logic and param-values goes here ...
     //

     public static Test suite() {
         return new CallbackTestSuite(MyTest.class);
     }
 }
 
To get an idea of how the above actually works under JUnit-3.8.x this article might shed some light.

Upgrade to JUnit-4.x and usage of CallbackParamsRunner is strongly recommended! Thereafter the above test-example should be refactored to ...
 @RunWith(CallbackParamsRunner.class)
 public class MyTest extends MockObjectTestCase {

     @ParameterizedCallback
     private CallbackInterface foo;

     //
     // ... Test-logic and param-values goes here ...
     //
 }
 
I.e. method suite() is replaced by the class-annotation @RunWith(CallbackParamsRunner.class) and the callback-injected field foo is annotated with @ParameterizedCallback. (Trying to use RunWith(CallbackParamsRunner.class) while still having suite() return a CallbackTestSuite instance will result in undefined incorrect behaviour.)

Author:
Henrik Kaipe

Constructor Summary
CallbackTestSuite(Class testClass)
           
CallbackTestSuite(Class testClass, CallbackRecordsFactory factory)
          Special constructor that allows the user to specify the CallbackRecordsFactory instance.
 
Method Summary
 
Methods inherited from class junit.framework.TestSuite
addTest, addTestSuite, countTestCases, createTest, getName, getTestConstructor, run, runTest, setName, testAt, testCount, tests, toString, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CallbackTestSuite

public CallbackTestSuite(Class testClass,
                         CallbackRecordsFactory factory)
Special constructor that allows the user to specify the CallbackRecordsFactory instance. This API is pretty much CallbackTestSuite's equivalent for CallbackTestCase.getCallbackRecordsFactory().

See Also:
CallbackRecordsFactory

CallbackTestSuite

public CallbackTestSuite(Class testClass)


Copyright © 2010-2013 Henrik Kaipe. All Rights Reserved.