ItemCount Property (Specific to Project Object)

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the TestItems.ItemCount property to obtain the total number of top-level test items in the given TestItems collection.

Declaration

Project TestItemsObj.ItemCount

Read-Only Property Integer
Project TestItemsObj An expression, variable or parameter that specifies a reference to a Project TestItems object

Applies To

The property is applied to the following object:

Property Value

The total number of top-level test items.

Example

The following example obtains the total number of project test items, iterates through them and posts their names to the test log.

JavaScript, JScript

function Test()
{
  var i, TestItems, Count;
  // Obtains the collection of project test items
  TestItems = Project.TestItems;
  // Defines the total number of test items in the project
  Count = TestItems.ItemCount;
  // Iterates through the project’s test items
  for (i = 0; i < Count; i++)
    ProcessTestItem(TestItems.TestItem(i));
}

function ProcessTestItem(ATestItem)
{
  // Posts the test item name
  Log.AppendFolder(ATestItem.Name);
  // If the test item contains child items, iterates through them
  for (var i = 0; i < ATestItem.ItemCount; i++)
    ProcessTestItem(ATestItem.TestItem(i));
  Log.PopLogFolder();
}

Python

def Test():
  # Obtains the collection of project test items
  TestItems = Project.TestItems
  # Defines the total number of test items in the project
  Count = TestItems.ItemCount
  # Iterates through the project's test items
  for i in range(0, Count):
    ProcessTestItem(TestItems.TestItem[i])

def ProcessTestItem(ATestItem):
  # Posts the test item name
  Log.AppendFolder(ATestItem.Name)
  # If the test item contains child items, iterates through them
  for i in range(0, ATestItem.ItemCount):
    ProcessTestItem(ATestItem.TestItem[i])
  Log.PopLogFolder()

VBScript

Sub Test
  Dim i, TestItems, Count
  ' Obtains the collection of project test items
  Set TestItems = Project.TestItems
  ' Defines the total number of test items in the project
  Count = TestItems.ItemCount
  ' Iterates through the project’s test items
  For i = 0 To Count-1
    ProcessTestItem(TestItems.TestItem(i))
  Next
End Sub

Sub ProcessTestItem(ATestItem)
  ' Posts the test item name
  Call Log.AppendFolder(ATestItem.Name)
  ' If the test item contains child items, iterates through them
  For i = 0 To ATestItem.ItemCount-1
    ProcessTestItem(ATestItem.TestItem(i))
  Next
  Log.PopLogFolder
End Sub

DelphiScript

procedure ProcessTestItem(ATestItem);
var i;
begin
  // Posts the test item name
  Log.AppendFolder(ATestItem.Name);
  // If the test item contains child items, iterates through them
  for i := 0 to ATestItem.ItemCount - 1 do
    ProcessTestItem(ATestItem.TestItem(i));
  Log.PopLogFolder();
end;

procedure Test();
var i, TestItems, Count;
begin
  // Obtains the collection of project test items
  TestItems := Project.TestItems;
  // Defines the total number of test items in the project
  Count := TestItems.ItemCount;
  // Iterates through the project’s test items
  for i := 0 to Count - 1 do
    ProcessTestItem(TestItems.TestItem(i));
end;

C++Script, C#Script

function Test()
{
  var i, TestItems, Count;
  // Obtains the collection of project test items
  TestItems = Project["TestItems"];
  // Defines the total number of test items in the project
  Count = TestItems["ItemCount"];
  // Iterates through the project’s test items
  for (i = 0; i < Count; i++)
    ProcessTestItem(TestItems["TestItem"](i));
}

function ProcessTestItem(ATestItem)
{
  // Posts the test item name
  Log["AppendFolder"](ATestItem["Name"]);
  // If the test item contains child items, iterates through them
  for (var i = 0; i < ATestItem["ItemCount"]; i++)
    ProcessTestItem(ATestItem["TestItem"](i));
  Log["PopLogFolder"]();
}

See Also

Current Property (Specific to Project Object)
TestItem Property (Specific to Project Object)

Highlight search results