Since version 4.3, variables can also be set explicitly from the results of a Java method call, which must return a String. The set tag needs to specify the class name and the method name to invoke, and the class must be in the CLASSPATH. An example of such a call is shown below:
<set name="${var}" static="true" class="com.mycompany.sqlunit.Utilities"
method="currentTimestamp">
<methodArgs>
<arg name="prefix" type="java.lang.String" value="MyPrefix" />
<arg name="format" type="java.lang.String" value="yyyyMMddhhmmss" />
</methodArgs>
</set>
|
In the above example, SQLUnit will call the method currentTimeStamp in the class com.mycompany.sqlunit.Utilities and populate the returned string into the ${var} variable in its symbol table. The ${var} can then be used by other tests in the suite.
public static String currentTimeStamp(String,String);
|