TestItem Property (Specific to ProjectSuite Object)

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

Description

Use the TestItems.TestItem property to obtain the test item of the current project suite by its index. The total number of test items is specified by the ItemCount property. To obtain the currently running test item, use the TestItems.Current property.

Declaration

ProjectSuite TestItemsObj.TestItem(Index)

Read-Only Property A TestItem object
ProjectSuite TestItemsObj An expression, variable or parameter that specifies a reference to a ProjectSuite TestItems object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

The zero-based index of the desired test item.

Property Value

The TestItem object that corresponds to the desired project in the current project suite.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the TestItem property in square brackets: TestItem[Index].

Example

The following example obtains the total number of project suite 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 suite test items
  TestItems = ProjectSuite.TestItems;
  // Defines the total number of test items in the project suite
  Count = TestItems.ItemCount;
  // Iterates through the project suite’s test items
  for (i = 0; i < Count; i++)
    Log.Message(TestItems.TestItem(i).ProjectName);
}

Python

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

VBScript

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

DelphiScript

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

C++Script, C#Script

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

See Also

TestItems.Current
TestItems.ItemCount

Highlight search results