Description
Use the TestItems.TestItem
property to obtain the top-level test item of the current project by its index. The total number of top-level test items is specified by the ItemCount
property.
To obtain the currently running test item (no matter if it is a top-level or a child test item), use the TestItems.Current
property.
Declaration
Project TestItemsObj.TestItem(Index)
Read-Only Property | A TestItem object |
Project TestItemsObj | An expression, variable or parameter that specifies a reference to a Project 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 top-level test item.
Property Value
The TestItem
object that corresponds to the desired top-level test item.
Remarks
If you use Python or DelphiScript, you should enclose the parameter of the TestItem
property in square brackets: TestItem[Index]
.
Example
The following code obtains a project’s test item by its index and posts information on this test item to the log.
JavaScript, JScript
{
var TestItems, Indx, TestItem;
// Obtains the project’s test items
TestItems = Project.TestItems;
// Sets the index of the test item
Indx = 0;
// Obtains the test item by its index
TestItem = TestItems.TestItem(Indx);
// Posts information on the test item to the log
Log.Message(TestItem.Name, TestItem.Description);
}
Python
def Test():
# Obtains the project's test items
TestItems = Project.TestItems
# Sets the index of the test item
Indx = 0
# Obtains the test item by its index
TestItem = TestItems.TestItem[Indx]
# Posts information on the test item to the log
Log.Message(TestItem.Name, TestItem.Description)
VBScript
Dim TestItems, Indx, TestItem
' Obtains the project’s test items
Set TestItems = Project.TestItems
' Sets the index of the test item
Indx = 0
' Obtains the test item by its index
Set TestItem = TestItems.TestItem(Indx)
' Posts information on the test item to the log
Call Log.Message(TestItem.Name, TestItem.Description)
End Sub
DelphiScript
var TestItems, Indx, TestItem;
begin
// Obtains the project’s test items
TestItems := Project.TestItems;
// Sets the index of the test item
Indx := 0;
// Obtains the test item by its index
TestItem := TestItems.TestItem(Indx);
// Posts information on the test item to the log
Log.Message(TestItem.Name, TestItem.Description);
end;
C++Script, C#Script
{
var TestItems, Indx, TestItem;
// Obtains the project’s test items
TestItems = Project["TestItems"];
// Sets the index of the test item
Indx = 0;
// Obtains the test item by its index
TestItem = TestItems["TestItem"](Indx);
// Posts information on the test item to the log
Log["Message"](TestItem["Name"], TestItem["Description"]);
}