Assertions

It is possible to define assertion data and also the assertion itself in the JTestCase XML. The structure of the assert tag usage is similar to the param tag usage:

The name attribute defines a name for the assertion. You can use this name in your code to identify the assertion.

The type attribute defines a data type for the assertion value.

The action attribute defines the assertion action that will be used if you want JTestCase to do the assertion for you. see assert action section.
Action attributes are specific to assert tags and don't belong to param tags.

The tag value defines the object your test case will be tested against.

<method name="method_name">
 <test-case name="name_your_test_case_here">
   <asserts>
     <assert_name="variable_name" 
           type="variable_type" 
           action="action_type">
        variable_value
     </assert>
    //.. other assertions
   </asserts>
 </test-case>
</method>

Assertions can be grouped in <assertgroup> tags.

<method name="method_name">
 <test-case name="name_your_test_case_here">
  <asserts>
    <assertgroup name="group_name>
      <assert_name="variable_name" 
           type="variable_type" 
           action="action_type">
        variable_value
      </assert>
      //.. other <assertgroup> or <assert> tags here
    </assertgroup>
    //.. other <assertgroup> or <assert> tags here
  </asserts>
</method>

This feature is helpful in the case that you need a lot of assertion data that has a hierarchy.

Complex data type like java.util.Hashtable can be used:

<method name="method_name">
 <test-case name="name_your_test_case_here">
  <asserts>
    <assert_type="java.util.Hashtable" key-type="java.lang.String" action="action_type">
     <assert_name="Test1" type="java.util.Hashtable" key-type="java.lang.String" value-type="java.lang.String" action="action_type">
        <assert_name="k1">value1</assert>
        <assert_name="k2">value2</assert>
        <assert_name="k3">value3</assert>
     </assert>
     <assert_name="k1" type="java.lang.String" action="action_type">value1</assert>
     <assert_name="k2" type="java.lang.Integer" action="action_type">42</assert>
    </assert>
  </asserts>
</method>