| java.lang.Object net.wangs.jtestcase.JTestCase
JTestCase | public class JTestCase (Code) | | This utility class is used for Unit test to help reading data (test cases) out from xml file.
author: Yuqing Wang |
Constructor Summary | |
public | JTestCase(String fileName, String className) Constructed from full file name and class name. |
Method Summary | |
public boolean | assertTestCase(String varName, Object varValue, String methodName, String testCase) Asserts a given varible's value against its expected value by using expected action.
Following actions are defined. | public boolean | assertTestCase(String varName, Object varValue, String methodName, int index) Asserts a given varible's value against its expected value by using expected action.
Following actions are defined. | public Hashtable | getAssertActions(String methodName, String testCase) Get all assert actions for a given method and its test case value into Hashtable. | public Hashtable | getAssertActions(String methodName, int index) Get all assert actions for a given method and its test case value into Hashtable. | public Hashtable | getAssertTypes(String methodName, String testCase) Get types of assert values for a given method and its test case value into Hashtable. | public Hashtable | getAssertTypes(String methodName, int index) Get types of 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 type of assert param. | public Hashtable | getAssertValues(String methodName, String testCase) Get all assert values for a given method and its test case value into Hashtable. | public Hashtable | getAssertValues(String methodName, int index) Get all assert values for a given method and its test case value into Hashtable. | public String | getClassUnderTest() | public Hashtable | getControlParams() Retrieves all control parameters. | public int | getCountOfTestCases(String methodName) Get number of test cases for a given method. | public String | getException(String methodName, String testCase) Get test cases exception name for a given method
Parameters: methodName - - name of tested method. | public String | getGlobalParamLocale() | public Hashtable | getGlobalParamTypes() Retrieves types of all global (class-wided) params into Hashtable. | public Hashtable | getGlobalParams() Retrieves all global (class-wide) params into Hashtable. | public Vector | getNameOfTestCases(String methodName) Get all test cases' name for a given method into Vector.
This method requires that for a given method, each test case should be named uniquely.
Parameters: methodName - - name of tested method. | public MultiKeyHashtable | getTestCaseAssertActions(String methodName, String testCase) Get all assert actions for a given method and its test case value into Hashtable. | public MultiKeyHashtable | getTestCaseAssertActions(String methodName, int index) Get all assert actions for a given method and its test case value into Hashtable. | public MultiKeyHashtable | getTestCaseAssertTypes(String methodName, String testCase) Get types of assert values for a given method and its test case value into Hashtable. | public MultiKeyHashtable | getTestCaseAssertTypes(String methodName, int index) Get types of 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 type of assert param. | public MultiKeyHashtable | getTestCaseAssertValues(String methodName, String testCase) Get all assert values for a given method and its test case value into Hashtable. | public MultiKeyHashtable | getTestCaseAssertValues(String methodName, int index) Get all assert values for a given method and its test case value into Hashtable. | public Hashtable | getTestCaseParamTypes(String methodName, String testCase) Get types of all params for a given method and its test case value into Hashtable. | public Hashtable | getTestCaseParamTypes(String methodName, int index) Get types of all params for a given method and the index number of test case into Hashtable. | public Object | getTestCaseParameter(String methodName, String testCase, String parameter) Get the value of the specific paramater given his name for a specific methodName
and a specific testCase.
Parameters: methodName - - name of tested method. | public Hashtable | getTestCaseParams(String methodName, String testCase) Get all params for a given method and its test case value into Hashtable. | public Hashtable | getTestCaseParams(String methodName, int index) Get all params for a given method and the index number of test case into Hashtable. |
JTestCase | public JTestCase(String fileName, String className) throws JTestCaseException(Code) | | Constructed from full file name and class name. This class name is specifed in data file
under "/tests/class@name". It's recommended that its value equals to the real testing
class's name.
Parameters: fileName - - name of data file. Will be searched by absolute path first. If not found,then will be searched based on classpath. Parameters: className - - name of test program. Is defined in data file in /tests/class@name throws: JTestCaseException - Problem with reading the file, validating the XML or with the XML structure |
assertTestCase | public boolean assertTestCase(String varName, Object varValue, String methodName, String testCase) throws JTestCaseException(Code) | | 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. Parameters: varValue - - actually value of this varible. Parameters: methodName - - name of this method. Defined in data file in /test/class/method@name. Parameters: testCase - - name of this test case. Defined in data file in /test/class/method@test-case. boolean. "true" is assertion is true, else "false". |
assertTestCase | public boolean assertTestCase(String varName, Object varValue, String methodName, int index) throws JTestCaseException(Code) | | 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. Parameters: varValue - - actually value of this varible. Parameters: methodName - - name of this method. Defined in data file in /test/class/method@name. Parameters: index - - index number of this test case for this method. boolean. "true" is assertion is true, else "false". |
getAssertActions | public Hashtable getAssertActions(String methodName, String testCase) throws JTestCaseException(Code) | | Get all assert actions for a given method and its test case value into Hashtable. Hashed key is
assert param's name, value is String value of assert action.
This method is normally used with getNameOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/asserts/assert@action. |
getAssertActions | public Hashtable getAssertActions(String methodName, int index) throws JTestCaseException(Code) | | Get all assert actions for a given method and its test case value into Hashtable. Hashed key
is assert param's name, value is String value of assert action.
This method os normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's action value defined in /test/class/method/asserts/assert@action. |
getAssertTypes | public Hashtable getAssertTypes(String methodName, String testCase) throws JTestCaseException(Code) | | Get types of 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 type of assert param. This type is name of java class.
This method does not return the types of assert values in complex data types. This means if you
have an assert value of type "java.util.Hashtable" this method returns exactly this string and not
a hashtable with the data types of the items in the hashtable.
This method is normally used with getNameOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: testCase - - name of test case.Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type. |
getAssertTypes | public Hashtable getAssertTypes(String methodName, int index) throws JTestCaseException(Code) | | Get types of 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 type of assert param. This type is name of java class.
This method does not return the types of assert values in complex data types. This means if you
have an assert value of type "java.util.Hashtable" this method returns exactly this string and not
a hashtable with the data types of the items in the hashtable.
This method os normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type. |
getAssertValues | public Hashtable getAssertValues(String methodName, String testCase) throws JTestCaseException(Code) | | 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().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". 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. |
getAssertValues | public Hashtable getAssertValues(String methodName, int index) throws JTestCaseException(Code) | | 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 os normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: index - - index number of test case for this method, start from 0. 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. |
getClassUnderTest | public String getClassUnderTest()(Code) | | Returns the class name used to find the class tags in XML
the class name |
getControlParams | public Hashtable getControlParams() throws JTestCaseException(Code) | | Retrieves all control parameters. Control parameters are parameters that are defined for
the whole JTestCase data set. They are valid for all class-tags in the file.
A hashtable with the control parameters. Key is defined in /tests/params/param@name,value is param's object value with type as indicated in /test/class/params/param@type. If "type" is not specified in data file, then "String" is default type. throws: JTestCaseException - in case of any errors |
getCountOfTestCases | public int getCountOfTestCases(String methodName) throws JTestCaseException(Code) | | Get number of test cases for a given method. This method name is specified in data file
in /tests/class/method@name. It's recommended that its value equals to the real
testing method's name.
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. int. Number of test cases that are defined for this method in data file. |
getException | public String getException(String methodName, String testCase) throws JTestCaseException(Code) | | Get test cases exception name for a given method
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. String representing the exception |
getGlobalParamTypes | public Hashtable getGlobalParamTypes() throws JTestCaseException(Code) | | Retrieves types of all global (class-wided) params into Hashtable. HashKey is param's name,
HashValue is param's type in String which represents java class's name.
These params are common to all tested methods for the specified tested class, and should be
retrieved in testing class's constructor.
Hashtable. Key is param's name defined in /tests/class/params/param@name, value is param's Object value with type as indecated in /test/class/params/param@type. If not "type" specified in data file, then "String" is default type. |
getGlobalParams | public Hashtable getGlobalParams() throws JTestCaseException(Code) | | Retrieves all global (class-wide) params into Hashtable. HashKey is param's name, HashValue
is param's value.
These params are common to all tested methods for the specified tested class, and should be
retrieved in testing class's constructor.
Hashtable. Key is param's name defined in /tests/class/params/param@name, value is param's Object value with type as indicated in /test/class/params/param@type. If not "type" specified in data file, then "String" is default type. |
getNameOfTestCases | public Vector getNameOfTestCases(String methodName) throws JTestCaseException(Code) | | Get all test cases' name for a given method into Vector.
This method requires that for a given method, each test case should be named uniquely.
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Vector of names of test cases that are defined for this method in data file in/tests/class/method@test-case. |
getTestCaseAssertActions | public MultiKeyHashtable getTestCaseAssertActions(String methodName, String testCase) throws JTestCaseException(Code) | | Get all assert actions for a given method and its test case value into Hashtable. Hashed key is
assert param's name, value is String value of assert action.
This method is normally used with getNameOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/asserts/assert@action. |
getTestCaseAssertActions | public MultiKeyHashtable getTestCaseAssertActions(String methodName, int index) throws JTestCaseException(Code) | | Get all assert actions for a given method and its test case value into Hashtable. Hashed key
is assert param's name, value is String value of assert action.
This method os normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's action value defined in /test/class/method/asserts/assert@action. |
getTestCaseAssertTypes | public MultiKeyHashtable getTestCaseAssertTypes(String methodName, String testCase) throws JTestCaseException(Code) | | Get types of 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 type of assert param. This type is name of java class.
This method does not return the types of assert values in complex data types. This means if you
have an assert value of type "java.util.Hashtable" this method returns exactly this string and not
a hashtable with the data types of the items in the hashtable.
This method is normally used with getNameOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: testCase - - name of test case.Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type. |
getTestCaseAssertTypes | public MultiKeyHashtable getTestCaseAssertTypes(String methodName, int index) throws JTestCaseException(Code) | | Get types of 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 type of assert param. This type is name of java class.
This method does not return the types of assert values in complex data types. This means if you
have an assert value of type "java.util.Hashtable" this method returns exactly this string and not
a hashtable with the data types of the items in the hashtable.
This method os normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type. |
getTestCaseAssertValues | public MultiKeyHashtable getTestCaseAssertValues(String methodName, String testCase) throws JTestCaseException(Code) | | 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().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". 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. |
getTestCaseAssertValues | public MultiKeyHashtable getTestCaseAssertValues(String methodName, int index) throws JTestCaseException(Code) | | 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 os normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Parameters: index - - index number of test case for this method, start from 0. 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. |
getTestCaseParamTypes | public Hashtable getTestCaseParamTypes(String methodName, String testCase) throws JTestCaseException(Code) | | Get types of all params for a given method and its test case value into Hashtable. Hashed key
is param's name, value is String value of param type, which conforms to java class name.
This method is normally used with getNameOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/params/param@type. |
getTestCaseParamTypes | public Hashtable getTestCaseParamTypes(String methodName, int index) throws JTestCaseException(Code) | | Get types of all params for a given method and the index number of test case into Hashtable. Hashed
key is param's name, value is String value of param type, which conforms to java class name.
This method is normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: index - - index number of test case for this method, start from 0. Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/params/param@type. |
getTestCaseParameter | public Object getTestCaseParameter(String methodName, String testCase, String parameter) throws JTestCaseException(Code) | | Get the value of the specific paramater given his name for a specific methodName
and a specific testCase.
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Parameters: parameter - the name of the parameter to be read. the value of the specific parameter for the specific method and testCase. since: 2.1.3 author: ckoelle |
getTestCaseParams | public Hashtable getTestCaseParams(String methodName, String testCase) throws JTestCaseException(Code) | | Get all params for a given method and its test case value into Hashtable. Hashed key
is param's name, value is value of param.
This method is normally used with getNameOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's Object value with type as indecated in /test/class/method/params/param@type. If not "type" specified in data file, then "String" is default type. |
getTestCaseParams | public Hashtable getTestCaseParams(String methodName, int index) throws JTestCaseException(Code) | | Get all params for a given method and the index number of test case into Hashtable. Hashed
key is param's name, value is String value of param.
This method is normally used with getCountOfTestCases().
Parameters: methodName - - name of tested method. Defined in data file in /tests/class/method@name. Parameters: index - - index number of test case for this method, start from 0. Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's Object value with type as indecated in /test/class/method/params/param@type. If not "type" specified in data file, then "String" is default type. |
|
|