org.jtestcase
Class TestCaseInstance

java.lang.Object
  extended by org.jtestcase.TestCaseInstance

public class TestCaseInstance
extends java.lang.Object

Object that holds the unique identifier for a test case in the sense of JTestCase. The test case can be described by the method name and the test case name.

Author:
Fausto Lelli, Christian Koelle

Constructor Summary
TestCaseInstance(java.lang.String method, java.lang.String testcase, JTestCase jtestcase)
           Constructor with initialization of the member variables.
 
Method Summary
 boolean assertTestVariable(java.lang.String varName, java.lang.Object varValue)
          Asserts a given varible's value against its expected value by using expected action.
 boolean equals(TestCaseInstance other)
          Test for equality
 java.lang.String getFailureReason()
          In case of failure, reports the test variables info that caused this test to fail.
 java.lang.String getMethod()
          Gets the name of the method.
 MultiKeyHashtable getTestCaseAssertParams()
          Get all assert params for a given method and its test case value into Hashtable.
 MultiKeyHashtable getTestCaseAssertValues()
          Get all assert values for a given method and its test case value into Hashtable.
 java.lang.String getTestCaseName()
          Gets the name of the testcase.
 java.util.HashMap getTestCaseParams()
           Get all params for a given TestCaseInstance.
 void setFailureReason(java.lang.String failureReason)
          Set test case failure Note that setting the test case failure before test failure has no effect.
 void setMethod(java.lang.String method)
          Sets the method member variable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestCaseInstance

public TestCaseInstance(java.lang.String method,
                        java.lang.String testcase,
                        JTestCase jtestcase)

Constructor with initialization of the member variables.

A test case instance should not be instantiated directly. Access TestCaseInstances using the getTestCasesInstancesInMethod() method of JTestCase class.

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

getFailureReason

public java.lang.String getFailureReason()
In case of failure, reports the test variables info that caused this test to fail.

Returns:
String

setFailureReason

public void setFailureReason(java.lang.String failureReason)
Set test case failure Note that setting the test case failure before test failure has no effect.


setMethod

public void setMethod(java.lang.String method)
Sets the method member variable.

Parameters:
method - the name of the method

getMethod

public java.lang.String getMethod()
Gets the name of the method.

Returns:
the name of the method

getTestCaseName

public java.lang.String getTestCaseName()
Gets the name of the testcase.

Returns:
the name of the testcase

equals

public boolean equals(TestCaseInstance other)
Test for equality

Parameters:
other - other JTestCaseIdentifier
Returns:
true if both objects are equal

getTestCaseParams

public java.util.HashMap getTestCaseParams()
                                    throws JTestCaseException

Get all params for a given TestCaseInstance. Hashed key is param's name, value is value of param. This method is normally used with getNameOfTestCases().

HashMap's key is param's name defined in /tests/class/method/params/param@name,

HashMap's value is param's Object value with type as indicated in /test/class/method/params/param@type.

Returns:
HashMap.
Throws:
JTestCaseException - if an internal error occurs

assertTestVariable

public boolean assertTestVariable(java.lang.String varName,
                                  java.lang.Object varValue)
                           throws JTestCaseException
Asserts a given varible's value against its expected value by using expected action. Following actions are defined. Expected action in data file should fall into one of them: ISNULL, ISNOTNULL, EQUALS, NOTEQUALS, GT (greater than), NOTGT (not greater than), LT (less than), NOTLT (not less than), and TRUE (expression is true). The expected asserting results are defined in data file like this:
...
       <asserts>
         <assert name="var1" action="EQUALS" type="int">100</assert>
         <assert name="var2" action="NOTNULL"/>
       </asserts>
      ...
 
Note: "GT" means "real value" greater than "expected value". Simular to others.

Parameters:
varName - - name of varible. Defined in data file in /test/class/method/asserts/assert@name.
varValue - - actually value of this varible.
Returns:
boolean. "true" is assertion is true, else "false".
Throws:
JTestCaseException - if an internal error occurs

getTestCaseAssertParams

public MultiKeyHashtable getTestCaseAssertParams()
                                          throws JTestCaseException
Get all assert params for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert param. This method is normally used with getNameOfTestCases().

Returns:
Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assertparm@name, value is assert param's Object value with type as indecated in /test/class/method/asserts/assert@type. If not "type" specified in data file, then "String" is default type.
Throws:
JTestCaseException - if an internal error occurs
java.io.FileNotFoundException

getTestCaseAssertValues

public MultiKeyHashtable getTestCaseAssertValues()
                                          throws JTestCaseException
Get all assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert param. This method is normally used with getNameOfTestCases().

Returns:
Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's Object value with type as indecated in /test/class/method/asserts/assert@type. If not "type" specified in data file, then "String" is default type.
Throws:
JTestCaseException - if an internal error occurs
java.io.FileNotFoundException