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
The Object.Run
method walks down the hierarchy of custom objects starting from the given object, calls methods and processes the object properties at each level. For more information on this, see the Controlling Object-Driven Tests topic.
Declaration
ObjectObj.Run()
ObjectObj | An expression, variable or parameter that specifies a reference to an Object object | |||
Result | None |
Applies To
The method is applied to the following object:
Result Value
None.
Example
The following example declares a new class, adds a property and a method to it and creates an object that contains an instance of the declared class. After that, it adds another property and method to the object and calls the Run
method that processes the object’s properties and executes the object’s methods.
JavaScript, JScript
{
var NewClass, MyObject;
// Declares a new class
NewClass = ODT.Classes.Declare("NewClass");
NewClass.AddProperty("ClassProperty", "Value");
NewClass.AddMethod("ClassMethod", "Unit1.Test1");
// Creates an object based on the declared class
MyObject = ODT.Classes.New("NewClass");
MyObject.AddProperty("ObjectProperty", 10);
MyObject.AddMethod("ObjectMethod", "Unit1.Test2");
// Enables all the object’s methods
for (var i = 0; i < MyObject.MethodCount; i++)
MyObject.Methods(i).Enabled = true;
// Processes the object’s properties and calls the object’s methods
MyObject.Run();
}
VBScript
' Declares a new class
Set NewClass = ODT.Classes.Declare("NewClass")
Call NewClass.AddProperty("ClassProperty", "Value")
Call NewClass.AddMethod("ClassMethod", "Unit1.Test1")
' Creates an object based on the declared class
Set MyObject = ODT.Classes.New("NewClass")
Call MyObject.AddProperty("ObjectProperty", 10)
Call MyObject.AddMethod("ObjectMethod", "Unit1.Test2")
' Enables all the object’s methods
For i = 0 To MyObject.MethodCount - 1
MyObject.Methods(i).Enabled = True
Next
' Processes the object’s properties and calls the object’s methods
MyObject.Run
End Sub
DelphiScript
var NewClass, MyObject, i;
begin
// Declares a new class
NewClass := ODT.Classes.Declare('NewClass');
NewClass.AddProperty('ClassProperty', 'Value');
NewClass.AddMethod('ClassMethod', 'Unit1.Test1');
// Creates an object based on the declared class
MyObject := ODT.Classes.New('NewClass');
MyObject.AddProperty('ObjectProperty', 10);
MyObject.AddMethod('ObjectMethod', 'Unit1.Test2');
// Enables all the object’s methods
for i := 0 to MyObject.MethodCount - 1 do
MyObject.Methods[i].Enabled := true;
// Processes the object’s properties and calls the object’s methods
MyObject.Run;
end;
C++Script, C#Script
{
var NewClass, MyObject;
// Declares a new class
NewClass = ODT["Classes"]["Declare"]("NewClass");
NewClass["AddProperty"]("ClassProperty", "Value");
NewClass["AddMethod"]("ClassMethod", "Unit1.Test1");
// Creates an object based on the declared class
MyObject = ODT["Classes"]["New"]("NewClass");
MyObject["AddProperty"]("ObjectProperty", 10);
MyObject["AddMethod"]("ObjectMethod", "Unit1.Test2");
// Enables all the object’s methods
for (var i = 0; i < MyObject["MethodCount"]; i++)
MyObject["Methods"](i)["Enabled"] = true;
// Processes the object’s properties and calls the object’s methods
MyObject["Run"]();
}
See Also
Run Method
Run Method
Run Method
Controlling Object-Driven Tests