Timeout Property

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

Description

Use this property to specify the maximum execution time of the test item in minutes. This property corresponds to the Timeout column of the project suite editor’s Test Items page.

Declaration

ProjectSuiteTestItem_COMAccessObj.Timeout

Read-Write Property Integer
ProjectSuiteTestItem_COMAccessObj An expression, variable or parameter that specifies a reference to a ProjectSuiteTestItem_COMAccess object

Applies To

The property is applied to the following object:

Property Value

Specifies the maximum execution time for the given test item in minutes.

Remarks

If this property is equal to 0, the timeout is ignored.

Example

The following example obtains the ProjectSuiteTests_COMAccess object and uses its properties to obtain the ProjectSuiteTestItem_COMAccess objects corresponding to individual project suite test items (projects). It displays project suite test items' properties and runs the test items one after another.

Visual Basic

Sub Test()

  Dim TestCompleteApp As TestCompleteApplication
  Dim IntegrationObject As ItcIntegration
  Dim LastResult As ItcIntegrationResultDescription

  ' Creates the application object
  Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication.14")

  ' Obtains the integration object
  Set IntegrationObject = TestCompleteApp.Integration

  ' Opens the project suite
  IntegrationObject.OpenProjectSuiteEx "C:\Work Folder\TestSuite\TestSuite.pjs"

  ' Needed to process errors
  Err.Clear
  On Error GoTo Err_Label

    ' Obtains the ProjectSuiteTestItems_COMAccess object
    Set PSTests = IntegrationObject.TestSuite("")
    ' Determines the number of test items (projects) the project suite contains
    Count = PSTests.Count

    If Count > 0 Then

      ' Iterates through the project suite test items
      For i = 0 To Count - 1
        ' Obtains the project suite test item
        Set PSTestItem = PSTests.TestItem(i)

        ' Checks whether the project suite test item is enabled
          If PSTestItem.Enabled Then
            ' Obtains the name of the test item (the project’s name)
            ProjectName = PSTestItem.ProjectName
            ' Obtains the file name of the project
            Location = PSTestItem.ProjectLocation
            ' Obtains the ProjectTests_COMAccess object corresponding to the project
            Set ProjectItem = PSTestItem.Project
            ' Obtains the number of project test items
            ChildItems = ProjectItem.Count
            ' Defines whether the project suite will be stopped if the project fails
            StopOnError = PSTestItem.StopOnError
            ' Obtains the maximum execution time for the current project
            Timeout = PSTestItem.Timeout
            ' Obtains the project description
            Description = PSTestItem.Description
            Info = "Name: " & ProjectName & VbCrLf & _
              "Location: " & Location & vbCrLf & _
              "Test items: " & ChildItems & vbCrLf & _
              "Stop on error: " & StopOnError & vbCrLf & _
              "Timeout: " & Timeout & vbCrLf & _
              "Description: " & Descriptiong & vbCrLf

            ' Displays project suite test item information
            UserForm1.Label1.Caption = Info

            ' Runs the project suite test item
            IntegrationObject.RunProject ProjectName
            ' Waits until the execution is over
            While IntegrationObject.IsRunning
              DoEvents
            Wend

            ' Checks the results
            Set LastResult = IntegrationObject.GetLastResultDescription
            Select Case LastResult.Status
              Case 0: MsgBox "The project run has finished successfully."
              Case 1: MsgBox "Warning messages were posted to the test log."
              Case 2: MsgBox "Error messages were posted to the test log."
            End Select

          End If

      Next

    End If

  Err_Label:
  ' Processes errors
  If Err.Number <> 0 Then
  MsgBox Err.Description, vbCritical, "Error"
  End If

  ' Closes TestComplete
  TestCompleteApp.Quit

End Sub

C#

using System.Runtime.InteropServices;
using TestComplete;



public partial class MainForm : Form
{
  public MainForm()
  {
    InitializeComponent();
  }
  private void btn_Connect_Click(object sender, EventArgs e)
  {
    const string TCProgID = "TestComplete.TestCompleteApplication.14";
    object TestCompleteObject = null;
    const string ProjectSuitePath = "C:\\Work Folder\\TestSuite\\TestSuite.pjs";
    // Obtains access to TestComplete
    try
    {
      TestCompleteObject = Marshal.GetActiveObject(TCProgID);
    }
    catch
    {
      try
      {
        TestCompleteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TCProgID));
      }
      catch
      {
      }
    }

    if (TestCompleteObject == null) return;

    // Obtains ITestCompleteCOMManager
    TestComplete.ITestCompleteCOMManager TestCompleteManager = (TestComplete.ITestCompleteCOMManager)TestCompleteObject;
    // Obtains the Integration object
    TestComplete.ItcIntegration IntegrationObject = TestCompleteManager.Integration;

    // We have a reference to the integration object
    // Now we can use its methods and properties to automate TestComplete

    // Loads the project suite
    IntegrationObject.OpenProjectSuiteEx(ProjectSuitePath);

    try
    {
      // Obtains the ProjectSuiteTestItems_COMAccess object
      object PSTestItems = IntegrationObject.get_TestSuite("");
      TestComplete.ItcProjectSuiteTests_COMAccess NewPSTestItems = null;
      NewPSTestItems = (TestComplete.ItcProjectSuiteTests_COMAccess)PSTestItems;

      // Determines the number of test items (projects) the project suite contains
      int Count = NewPSTestItems.Count;

      if (Count > 0)
      {
        // Iterates through the project suite test items
        for (var i = 0; i < Count; i++)
        {
          //Obtains the project suite test item
          TestComplete.ItcProjectSuiteTestItem_COMAccess PSTestItem = NewPSTestItems.get_TestItem(i);
          // Checks whether the project suite test item is enabled
          if (PSTestItem.Enabled)
          {
            // Obtains the ProjectTests_COMAccess object corresponding to the project
            TestComplete.ItcProjectTests_COMAccess ProjectItem = PSTestItem.Project;

            // Displays project suite test item information

            // Obtains the name of the test item (the project’s name)
            InfoTextBox.Text = "Name: " + PSTestItem.ProjectName + "\r\n";
            // Obtains the file name of the project
            InfoTextBox.Text += "Location: " + PSTestItem.ProjectLocation + "\r\n";
            // Obtains the number of project test items
            InfoTextBox.Text += "Test items: " + ProjectItem.Count + "\r\n";
            // Defines whether the project suite will be stopped if the project fails
            InfoTextBox.Text += "Stop on error: " + PSTestItem.StopOnError + "\r\n";
            // Obtains the maximum execution time for the current project
            InfoTextBox.Text += "Timeout: " + PSTestItem.Timeout + "\r\n";
            // Obtains the project description
            InfoTextBox.Text += "Description: " + PSTestItem.Description + "\r\n";
            // Runs the project suite test item
            IntegrationObject.RunProject(PSTestItem.ProjectName);

            // Waits until the execution is over
            while (IntegrationObject.IsRunning())

            Application.DoEvents();

            // Checks the results
            switch (IntegrationObject.GetLastResultDescription().Status)

            {
              case TestComplete.TC_LOG_STATUS.lsOk:
                System.Windows.Forms.MessageBox.Show(this, "The project run has finished successfully.");
                break;
              case TestComplete.TC_LOG_STATUS.lsWarning:
                System.Windows.Forms.MessageBox.Show(this, "Warning messages were posted to the test log.");
                break;
              case TestComplete.TC_LOG_STATUS.lsError:
                System.Windows.Forms.MessageBox.Show(this, "Error messages were posted to the test log.");
                break;
            }
          }
          InfoTextBox.Clear();
        }
      }
    }
    catch (System.Runtime.InteropServices.COMException ex)
    {
      System.Windows.Forms.MessageBox.Show("An exception occurred: " + ex.Message);
    }
    finally
    {
      // Closes TestComplete
      TestCompleteManager.Quit();
      // Releases COM objects
      Marshal.ReleaseComObject(IntegrationObject);
      Marshal.ReleaseComObject(TestCompleteManager);
      Marshal.ReleaseComObject(TestCompleteObject);
    }

  }
}

See Also

Working With TestComplete via COM - Overview
StopOnError Property
Enabled Property

Highlight search results