<objs><obj id="myId" type="my.class.Type" hint="call" calltype="my.call.Type" >...</obj><objs>
To define objects according to implemented specifications you must be able to
call the constructor of this object. Or even call a static method of a factory
class. This is just the way you do it in real application code.
Here is an example:
... <test id="mySecondTestCase"> <objs> <obj id="myObj" type="junitx.ddtunit.resources.SimpleVO" hint="call"> <item type="string">My Text</item> <item type="int">4711</item> <item type="double">12.4</item> </obj> </objs> </test> ...
public class SimpleVO { ... public SimpleVO(String text, Integer intValue, Double doubValue) { // whatever your class should do on instanciation } ...
<obj id="myObj" type="junitx.ddtunit.resources.SimpleVO" calltype="junitx.ddtunit.resources.SimpleVO" hint="call" method="constructor"> <item type="string">My Text</item> <item type="int">4711</item> <item type="double">12.4</item> </obj>
So you can see that there are three attributes to specify a method/constructor invokation:
<obj id="myObj" type="junitx.ddtunit.resources.SimpleVO" hint="call" method="toString" />
If you specify non static methods the framework will try to instanciate a calltype object by using default constructor.
Actually it is not important to use the <item/> tag name to
specify the parameters of the constructor. You can use any name that supports an
expressive meaning for the declaration.
To resolve the parameters only the type attribut and the order of the
parameters is used to specify the constructor call.
So the example above is equivalet to:
<obj id="myObj" type="junitx.ddtunit.resources.SimpleVO" calltype="junitx.ddtunit.resources.SimpleVO" hint="call" method="constructor"> <stringValue type="string">My Text</stringValue> <integerValue type="int">4711</integerValue> <doubleValue type="double">12.4</doubleValue> </obj>