扩展数据驱动

您必须在代理中实现 GetDataDrivableCommand() 方法,以添加控件的数据驱动支持。此方法返回方法规范,以实现对控件的数据驱动支持。使用数据驱动向导的同时,将 GetDataDrivableCommand() 返回的方法规范发送到测试脚本。代理可以覆盖和返回为数据驱动指定的所有方法。

开始之前

无需强制为每个控件添加数据驱动支持。 包含常规用户操作(如方法)和采用数据值(如参数)的控件,需要使用数据驱动。
要以扩展 表 1 中列出的方法:
表 1. 数据驱动的扩展方法
Java .Net
MethodSpecification getDataDrivableCommand() MethodSpecification GetDataDrivableCommand()

示例

以下样本采用 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.datapoolRef(getText())});
  }
 .
 .
}

以下样本采用 .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.DatapoolRef(text) } ); 
    }
    .
    .
   
}

下一步做什么

成功开发和部署此代理代码后,请通过使用 Functional Tester 数据驱动向导的数据驱动控件来对代码进行验证。将 TestObject.setText(dpString("text")) API 插入到测试脚本中。

反馈