The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.
Description
Use methods and properties of the ODT
object to create custom objects in scripts.
With methods and properties of the ODT
object, you can access other program objects used to work with custom objects and classes in scripts. The hierarchy of these objects is shown below. To read about any object listed in the hierarchy, click the object’s rectangle on the image:
The ODT
object is available only if your project contains the ODT project item.
Members
Example
The following example obtains the Data
object that provides access to data groups, posts the data groups’ names and the names of the variables stored in the groups to the test log.
JavaScript, JScript
{
var Data, Group, Variable;
// Obtains the Data object
Data = ODT.Data;
// Iterates through the data groups stored in the ODT project item
for (var i = 0; i < Data.GroupCount; i++)
{
Group = Data.Groups(i);
Log.AppendFolder(Group.Name);
// Iterates through the variables stored in the current data group
for (var j = 0; j < Group.VariableCount; j++)
{
Variable = Group.Variables(j);
Log.Message(Variable.Name);
}
Log.PopLogFolder();
}
}
VBScript
' Obtains the Data object
Set Data = ODT.Data
' Iterates through the data groups stored in the ODT project item
For i = 0 To Data.GroupCount - 1
Set Group = Data.Groups(i)
Log.AppendFolder Group.Name
' Iterates through the variables stored in the current data group
For j = 0 To Group.VariableCount - 1
Set Variable = Group.Variables(j)
Log.Message(Variable.Name)
Next
Log.PopLogFolder
Next
End Sub
DelphiScript
var Data, Group, Variable, i ,j;
begin
// Obtains the Data object
Data := ODT.Data;
// Iterates through the data groups stored in the ODT project item
for i := 0 to Data.GroupCount - 1 do
begin
Group := Data.Groups[i];
Log.AppendFolder(Group.Name);
// Iterates through the variables stored in the current data group
for j := 0 to Group.VariableCount - 1 do
begin
Variable := Group.Variables[j];
Log.Message(Variable.Name);
end;
Log.PopLogFolder;
end;
end;
C++Script, C#Script
{
var Data, Group, Variable;
// Obtains the Data object
Data = ODT["Data"];
// Iterates through the data groups stored in the ODT project item
for (var i = 0; i < Data["GroupCount"]; i++)
{
Group = Data["Groups"](i);
Log["AppendFolder"](Group["Name"]);
// Iterates through the variables stored in the current data group
for (var j = 0; j < Group["VariableCount"]; j++)
{
Variable = Group["Variables"](j);
Log["Message"](Variable["Name"]);
}
Log["PopLogFolder"]();
}
}