junit.framework
Class ForTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by junit.framework.ForTestCase
All Implemented Interfaces:
junit.framework.Test

public class ForTestCase
extends junit.framework.TestCase

This utility class extends the junit class TestCase to manage execution of tests based on JTestCase xml data.

Author:
Christophe Rochefolle

Constructor Summary
ForTestCase(java.lang.String name, java.lang.String file)
          Constructed from full file name and class name.
 
Method Summary
 void assertTestCase(java.lang.String name, java.lang.Object Value)
          Assert a testcase given a param to read in JTestCase, the value to compare for the current index
 void assertTestCase(java.lang.String name, java.lang.Object Value, int index)
          Assert a testcase given a param to read in JTestCase, the value to compare and testcase index
 int countTestCases()
          Counts the number of test cases executed by run(TestResult result).
 java.lang.String getdataFile()
          Gets the dataFile of a JTestCase
 java.lang.Object getGlobalParameters(java.lang.String name)
          Gets the value of a global parameter of a JTestCase
 java.util.Vector getTestCase()
          Gets the name of a JTestCase
 java.lang.String getTestCaseName()
          Gets the name of a JTestCase testcase for the current index
 java.lang.String getTestCaseName(int index)
          Gets the name of a JTestCase testcase for an index
 java.lang.Object getTestCaseParams(java.lang.String name)
          Gets the value of a parameter of a JTestCase testcase for the current index
 java.lang.Object getTestCaseParams(java.lang.String name, int index)
          Gets the value of a parameter of a JTestCase testcase for an index
 boolean mustFail()
          Gets the dataFile of a JTestCase
 void run(junit.framework.TestResult tr)
          Runs the test case and collects the results in TestResult.
 void setdataFile(java.lang.String file)
          Sets the dataFile of a JTestCase
 void setMustFail(boolean b)
          Sets if the test must fail
 java.lang.String toString()
          Returns a string representation of the test case
 
Methods inherited from class junit.framework.TestCase
getName, run, runBare, setName
 
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForTestCase

public ForTestCase(java.lang.String name,
                   java.lang.String file)
Constructed from full file name and class name. This class name is specifed in data file under "/tests/class@name". It's required that its value equals to the real testing class's name.

Parameters:
name - - name of test program. Is defined in data file in /tests/class@name
file - - name of data file. Will be searched by absolute path first. If not found, then will be searched based on classpath.
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the test case

Overrides:
toString in class junit.framework.TestCase
Returns:
a string representation of the test case

getTestCase

public java.util.Vector getTestCase()
                             throws java.lang.Exception
Gets the name of a JTestCase

Returns:
returns a String
Throws:
java.lang.Exception

getdataFile

public java.lang.String getdataFile()
Gets the dataFile of a JTestCase

Returns:
returns a String

setdataFile

public void setdataFile(java.lang.String file)
Sets the dataFile of a JTestCase

Parameters:
file - The name to set

mustFail

public boolean mustFail()
Gets the dataFile of a JTestCase

Returns:
returns a String

setMustFail

public void setMustFail(boolean b)
Sets if the test must fail

Parameters:
b - boolean

getGlobalParameters

public java.lang.Object getGlobalParameters(java.lang.String name)
Gets the value of a global parameter of a JTestCase

Parameters:
name - The name of the global parameter
Returns:
returns the corresponding value as an object

getTestCaseParams

public java.lang.Object getTestCaseParams(java.lang.String name,
                                          int index)
                                   throws java.lang.Exception
Gets the value of a parameter of a JTestCase testcase for an index

Parameters:
name - The name of the parameter
index - Index of the testcase
Returns:
returns the corresponding value as an object
Throws:
java.lang.Exception

getTestCaseParams

public java.lang.Object getTestCaseParams(java.lang.String name)
                                   throws java.lang.Exception
Gets the value of a parameter of a JTestCase testcase for the current index

Parameters:
name - The name of the parameter
Returns:
returns the corresponding value as an object
Throws:
java.lang.Exception

getTestCaseName

public java.lang.String getTestCaseName(int index)
                                 throws java.lang.Exception
Gets the name of a JTestCase testcase for an index

Parameters:
index - Index of the testcase
Returns:
returns a String
Throws:
java.lang.Exception

getTestCaseName

public java.lang.String getTestCaseName()
                                 throws java.lang.Exception
Gets the name of a JTestCase testcase for the current index

Returns:
returns a String
Throws:
java.lang.Exception

countTestCases

public int countTestCases()
Counts the number of test cases executed by run(TestResult result).

Specified by:
countTestCases in interface junit.framework.Test
Overrides:
countTestCases in class junit.framework.TestCase
Returns:
count of test cases

assertTestCase

public void assertTestCase(java.lang.String name,
                           java.lang.Object Value,
                           int index)
                    throws java.lang.Exception
Assert a testcase given a param to read in JTestCase, the value to compare and testcase index

Parameters:
name - The name of the parameter
Value - The value to compare
index - Index of the testcase
Throws:
java.lang.Exception

assertTestCase

public void assertTestCase(java.lang.String name,
                           java.lang.Object Value)
                    throws java.lang.Exception
Assert a testcase given a param to read in JTestCase, the value to compare for the current index

Parameters:
name - The name of the parameter
Value - The value to compare
Throws:
java.lang.Exception

run

public void run(junit.framework.TestResult tr)
Runs the test case and collects the results in TestResult.

Specified by:
run in interface junit.framework.Test
Overrides:
run in class junit.framework.TestCase
Parameters:
tr - the test result