Description
The TestItemElement
object provides a scripting interface to the entity executed by a project’s test item. It is specified in the Execution entity column on the Test Items page of the project editor.
To obtain a TestItemElement
object, use the TestItem.ElementToBeRun
property.
Members
Example
The following example obtains the name of the currently executed test and posts this name to the test log:
JavaScript, JScript
function Test()
{
var Tests, TestItem, Test;
// Obtains the project’s test items
Tests = Project.TestItems;
// Obtains the test item which is currently running
TestItem = Tests.Current;
// Obtains the test executed by the test item
Test = TestItem.ElementToBeRun;
// Posts the name of the executed test to the log
Log.Message("The " + Test.Caption + " test is being executed.");
}
{
var Tests, TestItem, Test;
// Obtains the project’s test items
Tests = Project.TestItems;
// Obtains the test item which is currently running
TestItem = Tests.Current;
// Obtains the test executed by the test item
Test = TestItem.ElementToBeRun;
// Posts the name of the executed test to the log
Log.Message("The " + Test.Caption + " test is being executed.");
}
Python
def Test():
# Obtains the project's test items
Tests = Project.TestItems
# Obtains the test item which is currently running
TestItem = Tests.Current
# Obtains the test executed by the test item
Test = TestItem.ElementToBeRun
# Posts the name of the executed test to the log
Log.Message("The " + Test.Caption + " test is being executed.")
VBScript
Sub Test
Dim Tests, TestItem, Test
' Obtains the project’s test items
Set Tests = Project.TestItems
' Obtains the test item which is currently running
Set TestItem = Tests.Current
' Obtains the test executed by the test item
Set Test = TestItem.ElementToBeRun
' Posts the name of the executed test to the log
Log.Message("The " & Test.Caption & " test is being executed.")
End Sub
Dim Tests, TestItem, Test
' Obtains the project’s test items
Set Tests = Project.TestItems
' Obtains the test item which is currently running
Set TestItem = Tests.Current
' Obtains the test executed by the test item
Set Test = TestItem.ElementToBeRun
' Posts the name of the executed test to the log
Log.Message("The " & Test.Caption & " test is being executed.")
End Sub
DelphiScript
procedure Test();
var Tests, TestItem, Test;
begin
// Obtains the project’s test items
Tests := Project.TestItems;
// Obtains the test item which is currently running
TestItem := Tests.Current;
// Obtains the test executed by the test item
Test := TestItem.ElementToBeRun;
// Posts the name of the executed test to the log
Log.Message('The ' + Test.Caption + ' test is being executed.');
end;
var Tests, TestItem, Test;
begin
// Obtains the project’s test items
Tests := Project.TestItems;
// Obtains the test item which is currently running
TestItem := Tests.Current;
// Obtains the test executed by the test item
Test := TestItem.ElementToBeRun;
// Posts the name of the executed test to the log
Log.Message('The ' + Test.Caption + ' test is being executed.');
end;
C++Script, C#Script
function Test()
{
var Tests, TestItem, Test;
// Obtains the project’s test items
Tests = Project["TestItems"];
// Obtains the test item which is currently running
TestItem = Tests["Current"];
// Obtains the test executed by the test item
Test = TestItem["ElementToBeRun"];
// Posts the name of the executed test to the log
Log["Message"]("The " + Test["Caption"] + " test is being executed.");
}
{
var Tests, TestItem, Test;
// Obtains the project’s test items
Tests = Project["TestItems"];
// Obtains the test item which is currently running
TestItem = Tests["Current"];
// Obtains the test executed by the test item
Test = TestItem["ElementToBeRun"];
// Posts the name of the executed test to the log
Log["Message"]("The " + Test["Caption"] + " test is being executed.");
}
See Also
Tests, Test Items, and Test Cases
Test Items Page (Project Editor)
ElementToBeRun Property