Parameters
In order define the input data for a test method you have to put <param>
tags into the
<method>
tags.
As you can see in the example parameters can be defined in a <param>
tag. This tag
has two attributes:
-
name
A name for the parameter. You can access the parameter in your code with this name.
-
type
The data type of the parameter (e.g. "String", "int" etc.).
The content of the <param>
tag is the value of the parameter. See
Use in JUnit to learn how to access the parameters in
your test code.
<method name="method name">
<test-case="name_your_test_case_here">
<params>
<param_name="variable_name" type="variable_type">variable_value</param>
//.. other parameters
</params>
</test-case>
</method>
|
Paramaters can be grouped in <paramgroup>
tags.
<method name="method name">
<test-case="name_your_test_case_here">
<params>
<paramgroup name="group name>
<param_name="variable_name" type="variable_type">variable_value</param>
//.. other <paramgroup> or <param> tags here
</paramgroup>
//.. other <paramgroup> or <param> tags here
</params>
</test-case>
</method>
|
This feature is helpful in the case that you need a lot of test data that has a hierarchy.
Complex data types like java.util.Hashtable
can be used:
<method name="method name">
<test-case="name_your_test_case_here">
<params>
<param_type="java.util.Hashtable" key-type="java.lang.String">
<param_name="Test1" type="java.util.Hashtable" key-type="java.lang.String" value-type="java.lang.String">
<param_name="k1">value1</param>
<param_name="k2">value2</param>
<param_name="k3">value3</param>
</param>
<param_name="k1" type="java.lang.String">value1</param>
<param_name="k2" type="java.lang.Integer">42</param>
</param>
</params>
</test-case>
</method>
|
See the data type section for more information about valid data types.