Name Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The aqTestCase.CurrentTestCase.Name property returns the name of the currently running test case.

In addition, TestComplete treats the following as test cases:

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 in the Execution Plan editor of the project, it is the value in the Name column of the editor.

  • 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.Begin and aqTestCase.End methods, it is the name set by the aqTestCase.Begin method.

  • 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

function Main()
{
  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

Sub Main
  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

procedure Main;
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

function Main()
{
  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 Squad

Highlight search results