net.sf.saffron.util
Class MethodCallTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--net.sf.saffron.util.MethodCallTestCase
All Implemented Interfaces:
Test

public class MethodCallTestCase
extends TestCase

A MethodCallTestCase is a TestCase which invokes a method on an object. You can use this class to expose methods of a non-TestCase class as unit tests; addTestMethods(junit.framework.TestSuite, java.lang.Object, net.sf.saffron.util.MethodCallTestCase.Dispatcher) does this for all public, non-static, void methods whose names start with "test", and have one .

Since:
Mar 19, 2003
Version:
$Id: //open/saffron/src/net/sf/saffron/util/MethodCallTestCase.java#2 $
Author:
jhyde

Nested Class Summary
static interface MethodCallTestCase.Dispatcher
          A class implementing Dispatcher calls a method from within its own security context.
 
Field Summary
private  Object[] args
           
private  MethodCallTestCase.Dispatcher dispatcher
           
private  Method method
           
private  Object o
           
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
(package private) MethodCallTestCase(String name, Object o, Method method, MethodCallTestCase.Dispatcher dispatcher)
           
 
Method Summary
static void addTestMethods(TestSuite suite, Object o, MethodCallTestCase.Dispatcher dispatcher)
           
static boolean isSuitable(Method method)
          Returns whether a method can be called as a test case; it must: be public be non-static return void begin with test have precisely one parameter of type TestCase (or a class derived from it)
protected  void runTest()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dispatcher

private final MethodCallTestCase.Dispatcher dispatcher

method

private final Method method

o

private final Object o

args

private final Object[] args
Constructor Detail

MethodCallTestCase

MethodCallTestCase(String name,
                   Object o,
                   Method method,
                   MethodCallTestCase.Dispatcher dispatcher)
Method Detail

isSuitable

public static boolean isSuitable(Method method)
Returns whether a method can be called as a test case; it must:
  1. be public
  2. be non-static
  3. return void
  4. begin with test
  5. have precisely one parameter of type TestCase (or a class derived from it)


addTestMethods

public static void addTestMethods(TestSuite suite,
                                  Object o,
                                  MethodCallTestCase.Dispatcher dispatcher)

runTest

protected void runTest()
                throws Throwable
Overrides:
runTest in class TestCase
Throwable

SourceForge.net_Logo