MethodCount Property

Applies to TestComplete 14.60, last modified on April 22, 2021

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 the Class.MethodCount property to get the total number of methods in the specified class.

Declaration

ClassObj.MethodCount

Read-Only Property Integer
ClassObj An expression, variable or parameter that specifies a reference to a Class object

Applies To

The property is applied to the following object:

Property Value

The total number of methods in the class.

Example

The code below posts the names of all the methods that belong to the MyClass class to the test log.

JavaScript, JScript

function MethodCountExample()
{
  // Specifies the class name
  var MyClass = ODT.Classes.MyClass;
  // Obtains the total number of the class's methods
  var MethNum = MyClass.MethodCount;
  
  // Iterates through the methods
  for (var i = 0; i < MethNum; i++)
  {
    var MethName = MyClass.Methods(i).Name;
    // Posts a method's name to the test log
    Log.Message(MethName);
  }
}

VBScript

Sub MethodCountExample()

  ' Specifies the class name
  Set MyClass = ODT.Classes.MyClass
  ' Obtains the total number of the class's methods
  MethNum = MyClass.MethodCount
  
  ' Iterates through the methods
  For i = 0 to (MethNum - 1)
    MethName = MyClass.Methods(i).Name
    ' Posts a method's name to the test log
    Log.Message(MethName)
  Next

End Sub

DelphiScript

function MethodCountExample;
var MyClass, MethNum, i, MethName;
begin

  // Specifies the class name
  MyClass := ODT.Classes.MyClass;
  // Obtains the total number of the class's methods
  MethNum := MyClass.MethodCount;
  
  // Iterates through the methods
  for i := 0 to (MethNum - 1) do
  begin
    MethName := MyClass.Methods[i].Name;
    // Posts a method's name to the test log
    Log.Message(MethName);
  end;

end;

C++Script, C#Script

function MethodCountExample()
{
  // Specifies the class name
  var MyClass = ODT["Classes"]["MyClass"];
  // Obtains the total number of the class's methods
  var MethNum = MyClass["MethodCount"];
  
  // Iterates through the methods
  for (var i = 0; i < MethNum; i++)
  {
    var MethName = MyClass["Methods"](i)["Name"];
    // Posts a method's name to the test log
    Log["Message"](MethName);
  }
}

See Also

Methods Property
Properties Property
PropertyCount Property
MethodCount Property

Highlight search results