Extending data driving

You must implement the GetDataDrivableCommand() method in the proxy to add data driving support to a control. This method returns a method specification to implement data driving support for a control. While using the data driving wizard, the method specification that GetDataDrivableCommand() returns is sent to the test script. Proxies can override and return any method that you specify for data driving.

Before you begin

It is not mandatory to add data driving support for every control. Data driving is useful for controls that have common user actions such as a method, and that take data values, such as parameters.
You can extend the methods listed in Extensible methods for data driving:
Table 1. Extensible methods for data driving
Java .Net
MethodSpecification getDataDrivableCommand() MethodSpecification GetDataDrivableCommand()

Example

The following sample adds data driving support in Java:
import com.rational.test.ft.domain.*;

public class newProxy extends baseProxy
{
 .
 .
 public MethodSpecification getDataDrivableCommand()
 {
    if ( !isEditable() )
	return null;
    return MethodSpecification.proxyMethod(
	this, "setText", new Object[]{MethodSpecification.datasetRef(getText())});
  }
 .
 .
}

The following sample adds data driving support in .Net:

using Rational.Test.Ft.Domain;
using Rational.Test.Ft.Sys;

public class NewProxy:BaseProxy
{
     .
     .
     .
    public override MethodSpecification GetDataDrivableCommand()
    {
       System.String text = GetText();
       if ( text == null )
	  text = "";
       return MethodSpecification.ProxyMethod(
	 this, "SetText", new System.Object[]{ MethodSpecification.datasetRef(text) } ); 
    }
    .
    .
   
}

What to do next

After successfully developing and deploying this proxy code, verify it by data driving the control using the Test UI data driving wizard. The TestObject.setText(dpString("text")) API is inserted into the test script.