Defining Constant Objects

<objs><obj id="myId" type="my.class.Type" hint="constant">...</obj><objs>

To define constants you need to know the naming of the fields you want to reference. The attribute obj@type is that of the class containing the constant field you want to reference. In general this is not the type of the field itself.
The only restriction stated: the field must be defined static.
The Java 5 Enumeration type is supported as well. Here is an example:

<test id="myFirstTestCase">
   <objs>
     <obj id="myObj" type="junitx.ddtunit.resources.SimpleConstants"
       hint="constant">MY_STRING_CONSTANT</obj>
   </objs>
 </test>
where the object identified by obj@id="myObj" reflects a Java object definition like in the next example
 public class SimpleConstants {
  public final static String MY_STRING_CONSTANT = "Hallo World";
  /** 
   * Default constructor. 
   */
  private SimpleConstants() { 
    // no special initialization neccessary 
  }
<test id="mySecondTestCase">
   <objs>
     <obj id="myObj" type="junitx.ddtunit.resources.MyEnumerator"
       hint="constant">FIRST_ENUMERATOR</obj>
   </objs>
 </test>
where the object identified by obj@id="myObj" reflects a Java object definition like in the next example
 public public enum MyEnumerator {
	FIRST_ENUMERATION, SECOND_ENUMERATION, NULL
}
sf logo