Description
The aqTestCase.CurrentTestCase.Name property returns the name of the currently running test case.
-
You can specify test cases on the Test Items page of your project.
-
You can specify arbitrary code fragments as test cases manually by using the
aqTestCase.BeginandaqTestCase.Endmethods.
In addition, TestComplete treats the following as test cases:
-
All the tests you run by selecting their tag.
Declaration
TestCaseObj.Name
| Read-Only Property | String |
| TestCaseObj | An expression, variable or parameter that specifies a reference to a TestCase object | |||
Applies To
The property is applied to the following object:
Property Value
The name of the current test case.
-
For test cases specified on the Test Item page of the project, it is the value in the Name column of the page.
-
For tests that were selected by their tags, it is the test name. For keyword tests, it is the name you can see in the Project Explorer panel under the Keyword Tests node. For scripts, it is the appropriate routine name or the custom test case name specified by using tags.
-
For test cases specified by using the
aqTestCase.BeginandaqTestCase.Endmethods, it is the name set by theaqTestCase.Beginmethod. -
For BDD scenarios, it is the scenario description.
If no test case is currently running, the aqTestCase.CurrentTestCase property will return an empty value (null in JavaScript, JScript, C#Script and C++Script, None in Python, Nothing in VBScript, nil in DelphiScript). No Name property will be available.
Example
The following sample shows how to post the name of the current test case to the test log:
JavaScript, JScript
{
var page = Aliases.browser.page;
var panel = page.Aspnetform.panel;
…
// Sets the beginning of the "Create an order" test
aqTestCase.Begin("Create an order");
try{
page.Aspnetform.table.cell1.linkOrder.Click();
…
}
catch (e){
Log.Warning("Test case \"" + aqTestCase.CurrentTestCase.Name + "\" failed");
}
finally{
// Sets the end of the "Create order" test
aqTestCase.End();
}
…
Aliases.browser.Close();
}
Python
def main():
page = Aliases.browser.page
panel = page.Aspnetform.panel
# Sets the beginning of the "Create an order" test
aqTestCase.Begin("Create an order");
try:
page.Aspnetform.table.cell1.linkOrder.Click()
#...
except Exception as e:
Log.Warning("Test case \"" + aqTestCase.CurrentTestCase.Name + "\" failed")
finally:
# Sets the end of the "Create order" test
aqTestCase.End()
#...
Aliases.browser.Close()
VBScript
Dim page
Set page = Aliases.browser.page
Dim panel
Set panel = page.Aspnetform.panel
…
' Sets the beginning of the "Create an order" test
aqTestCase.Begin("Create an order")
On Error Resume Next
Call page.Aspnetform.table.cell1.linkOrder.Click
…
If Err.Number <> 0 Then
Log.Error("Test case """ & aqTestCase.CurrentTestCase.Name & """ failed")
End If
' Sets the end of the "Create order" test
aqTestCase.End
…
Call Aliases.browser.Close
End Sub
DelphiScript
var page, panel;
begin
page := Aliases.browser.page;
panel := page.Aspnetform.panel;
…
// Sets the beginning of the "Create an order" test
aqTestCase.Begin('Create an order');
try
begin
page.Aspnetform.table.cell1.linkOrder.Click;
…
end;
except
Log.Warning('Test case "' + aqTestCase.CurrentTestCase.Name + '" failed');
end;
// Sets the end of the "Create order" test
aqTestCase.End;
…
Aliases.browser.Close();
end;
C++Script, C#Script
{
var page = Aliases["browser"]["page"];
var panel = page["Aspnetform"]["panel"];
…
// Sets the beginning of the "Create an order" test
aqTestCase["Begin"]("Create an order");
try{
page["Aspnetform"]["table"]["cell1"]["linkOrder"]["Click"]();
…
}
catch (e){
Log["Warning"]("Test case \"" + aqTestCase["CurrentTestCase"]["Name"] + "\" failed");
}
finally{
// Sets the end of the "Create order" test
aqTestCase["End"]();
}
…
Aliases["browser"]["Close"]();
}
See Also
TestCase Object
Begin Method
Getting Current Test Name
Summary Report
Integration With Zephyr for Jira

Script tags