aqTestCase Object

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

Description

The aqTestCase object allows marking arbitrary parts of your script code as test cases. These code parts will be treated as separate tests and will be included in the Summary report:

Test Cases in the Summary report

Click the image to enlarge it.

During the test run, the object also allows accessing the current test case regardless of whether it was specified by the aqTestCase.Begin method, on the Test Items page of your project, or by tags.

Requirements

TestComplete version 14.1 or later.

Members

Example

The following sample code marks a part of the Main routine as the Create an order test:

JavaScript, JScript

function Main()
{
  var page = Aliases.browser.page;
  var panel = page.Aspnetform.panel;

  panel.Username.SetText("Tester");
  panel.Password.SetText("test");
  panel.submitbutton.Click();
  page.Wait();

  // Sets the beginning of the "Create an order" test
  aqTestCase.Begin("Create an order");
  try{

    page.Aspnetform.table.cell1.linkOrder.Click();
    page.Wait();

    var cell = page.Aspnetform.table.cell.panelContent.tableorder.cell;
    cell.selectProduct.ClickItem("ScreenSaver");
    …
    cell.panel.linkProcess.Click();

    page.Wait();
    page.Aspnetform.table.cell1.linkViewAllOrders.Click();
    page.Wait();

  }
  catch (e){
    …
  }

  finally{
    // Sets the end of the "Create order" test
    aqTestCase.End();
  }

  var table = page.Aspnetform.table.cell.panelContent.panel.table;
  table.Cell(1, table.ColumnCount(1) - 1).ImageButton(0).Click();
  page.Wait();

  …

  Aliases.browser.Close();
}

Python

def main():
  page = Aliases.browser.page 

  panel = page.Aspnetform.panel
  panel.Username.SetText("Tester")
  panel.Password.SetText("test")
  panel.submitbutton.Click()
  page.Wait()
  
  # Sets the beginning of the "Create an order" test
  aqTestCase.Begin("Create an order");
  try:
    page.Aspnetform.table.cell1.linkOrder.Click()
    page.Wait()

    cell = page.Aspnetform.table.cell.panelContent.tableorder.cell
    cell.selectProduct.ClickItem("ScreenSaver")
    #...
    cell.panel.linkProcess.Click()
  
    page.Wait()
    page.Aspnetform.table.cell1.linkViewAllOrders.Click()
    page.Wait()
  except Exception as e:
    #...
  finally:
    # Sets the end of the "Create order" test
    aqTestCase.End()
  
  table = page.Aspnetform.table.cell.panelContent.panel.table
  table.Cell(1, table.ColumnCount[1] - 1).ImageButton(0).Click()
  page.Wait()
  
  #...
  Aliases.browser.Close()

VBScript

Sub Main
  Dim page, table, settings
  Set page = Aliases.browser.page
  Dim panel
  Set panel = page.Aspnetform.panel
  Call panel.Username.SetText("Tester")
  Call panel.Password.SetText("test")
  Call panel.submitbutton.Click()
  Call page.Wait

  ' Sets the beginning of the "Create an order" test
  aqTestCase.Begin("Create an order")
  On Error Resume Next

    Dim cell
    Call page.Aspnetform.table.cell1.linkOrder.Click
    Call page.Wait

    Set cell = page.Aspnetform.table.cell.panelContent.tableorder.cell
    Call cell.selectProduct.ClickItem("ScreenSaver")
    …
    Call cell.panel.linkProcess.Click

    Call page.Wait
    Call page.Aspnetform.table.cell1.linkViewAllOrders.Click
    Call page.Wait

  If Err.Number <> 0 Then
    …
  End If
  ' Sets the end of the "Create order" test
  aqTestCase.End

  Set table = page.Aspnetform.table.cell.panelContent.panel.table
  Call table.Cell(1, table.ColumnCount(1) - 1).ImageButton(0).Click
  Call page.Wait

  …

  Call Aliases.browser.Close
End Sub

DelphiScript

procedure Main;
var page, panel, table, cell;
begin
  page := Aliases.browser.page;

  panel := page.Aspnetform.panel;
  panel.Username.SetText('Tester');
  panel.Password.SetText('test');
  panel.submitbutton.Click;
  page.Wait;

  // Sets the beginning of the "Create an order" test
  aqTestCase.Begin('Create an order');
  try
  begin
    page.Aspnetform.table.cell1.linkOrder.Click;
    page.Wait;
    cell := page.Aspnetform.table.cell.panelContent.tableorder.cell;
    cell.selectProduct.ClickItem('ScreenSaver');
    …
    cell.panel.linkProcess.Click;
    page.Wait;
    page.Aspnetform.table.cell1.linkViewAllOrders.Click;
    page.Wait;
  end;
  finally
    // Sets the end of the "Create order" test
    aqTestCase.End;
  end;
  table := page.Aspnetform.table.cell.panelContent.panel.table;
  table.Cell(1, table.ColumnCount[1] - 1).ImageButton(0).Click;
  page.Wait;

  …

  Aliases.browser.Close();
end;

C++Script, C#Script

function Main()
{
  var page = Aliases["browser"]["page"];
  var panel = page["Aspnetform"]["panel"];

  panel["Username"]["SetText"]("Tester");
  panel["Password"]["SetText"]("test");
  panel["submitbutton"]["Click"]();
  page["Wait"]();

  // Sets the beginning of the "Create an order" test
  aqTestCase["Begin"]("Create an order");
  try{

    page["Aspnetform"]["table"]["cell1"]["linkOrder"]["Click"]();
    page["Wait"]();

    var cell = page["Aspnetform"]["table"]["cell"]["panelContent"]["tableorder"]["cell"];
    cell["selectProduct"]["ClickItem"]("ScreenSaver");
    …
    cell["panel"]["linkProcess"]["Click"]();

    page["Wait"]();
    page["Aspnetform"]["table"]["cell1"]["linkViewAllOrders"]["Click"]();
    page["Wait"]();

  }
  catch (e){
    …
  }

  finally{
    // Sets the end of the "Create order" test
    aqTestCase["End"]();
  }

  var table = page["Aspnetform"]["table"]["cell"]["panelContent"]["panel"]["table"];
  table["Cell"](1, table["ColumnCount"](1) - 1)["ImageButton"](0)["Click"]();
  page["Wait"]();

  …

  Aliases["browser"]["Close"]();
}

See Also

Summary Report
About Test Cases and Summary Reports

Highlight search results