TestItem Object (Specific to ProjectSuite Object)

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

Description

The TestItem object provides access to a test item defined in your project suite and allows you to get the project’s property values. Note that all of the TestItem object properties are read-only and cannot be changed during the test run. To set up the project suite’s test items, use the Test Items page of the project suite editor.

Members

Example

The following example iterates through a project’s test items and posts their properties to the test log:

JavaScript, JScript

function Test() {
  // Iterates through test items
  for (i = 0; i< ProjectSuite.TestItems.ItemCount; i++) {
    LogTestItemInfo(ProjectSuite.TestItems.TestItem(i));
  }
}

function LogTestItemInfo(ATestItem) {
  // Prints the test item name
  Log.AppendFolder(ATestItem.ProjectName);
  // Prints the test item description
  Log.Message(ATestItem.Description);
  // Prints the corresponding project location
  Log.Message(ATestItem.ProjectLocation);
  // Determines whether the current test item is enabled
  Log.Message(ATestItem.Enabled);
  // Obtains the test item’s StopOnError property value
  Log.Message(ATestItem.StopOnError);
  // Prints the test item’s timeout
  Log.Message(ATestItem.Timeout);
  Log.PopLogFolder();
}

Python

def Test():
  # Iterates through test items 
  for i in range (0, ProjectSuite.TestItems.ItemCount):
    LogTestItemInfo(ProjectSuite.TestItems.TestItem[i])

def LogTestItemInfo(ATestItem):
  # Prints the test item name 
  Log.AppendFolder(ATestItem.ProjectName)
  # Prints the test item description
  Log.Message(ATestItem.Description)
  # Prints the corresponding project location
  Log.Message(ATestItem.ProjectLocation)
  # Determines whether the current test item is enabled 
  Log.Message(ATestItem.Enabled)
  # Obtains the test item's StopOnError property value 
  Log.Message(ATestItem.StopOnError)
  # Prints the test item's timeout 
  Log.Message(ATestItem.Timeout)
  Log.PopLogFolder();

VBScript

Sub Test()
  Dim i
  ' Iterates through test items
  For i = 0 To ProjectSuite.TestItems.ItemCount - 1
    LogTestItemInfo(ProjectSuite.TestItems.TestItem(i))
  Next 

End Sub 

Sub LogTestItemInfo(ATestItem)
  ' Prints the test item name
  Log.AppendFolder(ATestItem.ProjectName)
  ' Prints the test item description
  Log.Message(ATestItem.Description)
  ' Prints the corresponding project location
  Log.Message(ATestItem.ProjectLocation)
  ' Determines whether the current test item is enabled
  Log.Message(ATestItem.Enabled)
  ' Obtains the test item’s StopOnError property value
  Log.Message(ATestItem.StopOnError)
  ' Prints the test item’s timeout
  Log.Message(ATestItem.Timeout)
  Log.PopLogFolder
End Sub 

DelphiScript

procedure LogTestItemInfo(ATestItem);
begin
  // Prints the test item name
  Log.AppendFolder(ATestItem.ProjectName);
  // Prints the test item description
  Log.Message(ATestItem.Description);
  // Prints the corresponding project location
  Log.Message(ATestItem.ProjectLocation);
  // Determines whether the current test item is enabled
  Log.Message(ATestItem.Enabled);
  // Obtains the test item’s StopOnError property value
  Log.Message(ATestItem.StopOnError);
  // Prints the test item’s timeout
  Log.Message(ATestItem.Timeout);
  Log.PopLogFolder();
end;

procedure Test();
var i;
begin
  // Iterates through test items
  for i := 0 to ProjectSuite.TestItems.ItemCount-1 do 
    LogTestItemInfo(ProjectSuite.TestItems.TestItem(i));
end;

C++Script, C#Script

function Test()
{
  // Iterates through test items
  for (i = 0; i< ProjectSuite["TestItems"]["ItemCount"]; i++)
  {
    LogTestItemInfo(ProjectSuite["TestItems"]["TestItem"](i));
  }
}

function LogTestItemInfo(ATestItem)
{
  // Prints the test item name
  Log["AppendFolder"](ATestItem.ProjectName);
  // Prints the test item description
  Log["Message"](ATestItem.Description);
  // Prints the corresponding project location
  Log["Message"](ATestItem.ProjectLocation);
  // Determines whether the current test item is enabled
  Log["Message"](ATestItem.Enabled);
  // Obtains the test item’s StopOnError property value
  Log["Message"](ATestItem.StopOnError);
  // Prints the test item’s timeout
  Log["Message"](ATestItem.Timeout);
  Log["PopLogFolder"]();
}

See Also

Tests, Test Items, and Test Cases
Test Items Page (Project Suite Editor)
TestItem Property (Specific to ProjectSuite Object)

Highlight search results