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 MethodDeclaration object provides a scripting interface to methods of ODT classes. It represents a “declaration” of a class method and provides properties that let you specify the method name and the script routine used as the given method.
Note that to work with methods of objects that are class instances created via the Classes.New method, the Method object is used.
To obtain the MethodDeclaration in your scripts, use the Methods property of the Class object.
Members
Example
The following example demonstrates how you can obtain a MethodDeclaration object in your script.
JavaScript, JScript
{
// Obtains the ODT class by its name
var ClassObj = ODT.Classes.Items("NewClass");
// Obtains the declaration of the class method by the method’s index
var MethodDecl = ClassObj.Methods(0);
// Posts the method’s names and the name of the script routine assigned to the method
Log.Message(MethodDecl.Name, MethodDecl.ScriptProc);
…
}
VBScript
' Obtains the ODT class by its name
Set ClassObj = ODT.Classes.Items("NewClass")
' Obtains the declaration of the class method by the method’s index
Set MethodDecl = ClassObj.Methods(0)
' Posts the method’s names and the name of the script routine assigned to the method
Call Log.Message(MethodDecl.Name, MethodDecl.ScriptProc)
…
End Sub
DelphiScript
var ClassObj, MethodDecl;
begin
// Obtains the ODT class by its name
ClassObj := ODT.Classes.Items('NewClass');
// Obtains the declaration of the class method by the method’s index
MethodDecl := ClassObj.Methods[0];
// Posts the method’s names and the name of the script routine assigned to the method
Log.Message(MethodDecl.Name, MethodDecl.ScriptProc);
…
end;
C++Script, C#Script
{
// Obtains the ODT class by its name
var ClassObj = ODT["Classes"]["Items"]("NewClass");
// Obtains the declaration of the class method by the method’s index
var MethodDecl = ClassObj["Methods"](0);
// Posts the method’s names and the name of the script routine assigned to the method
Log["Message"](MethodDecl["Name"], MethodDecl["ScriptProc"]);
…
}
See Also
Object-Driven Testing
Class Object
Methods Property
Method Object
PropertyDeclaration Object

Properties