StopWatch Object

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

The StopWatch object adds the stopwatch functionality to TestComplete so that you can measure time intervals up to 100 hours long.

The HISUtils object is available only if the HISUtils plugin (<TestComplete>\Bin\Extensions\tcHISUtils.pls) is installed. For information on how to install plugins in TestComplete, see Installing Extensions.

Members

Example

The following code snippet starts a test and measures how much time has been spent on it execution.

JavaScript, JScript

function Test()
{
  var StopWatch;
  StopWatch = HISUtils.StopWatch;
  // Starts the time counter
  StopWatch.Start();
  DoTest1();
  // Stops the time counter
  StopWatch.Stop();
  // Posts the passed time to the test log
  Log.Message("Test1 finished. Execution time: " + StopWatch.ToString());

}

Python

def Test():

  StopWatch = HISUtils.StopWatch
  # Starts the time counter
  StopWatch.Start()
  DoTest1()
  # Stops the time counter
  StopWatch.Stop()
  # Posts the passed time to the test log
  Log.Message("Test1 finished. Execution time: " + StopWatch.ToString())

VBScript

Sub Test

  Dim StopWatch
  Set StopWatch = HISUtils.StopWatch
  ' Starts the time counter
  StopWatch.Start
  DoTest1
  ' Stops the time counter
  StopWatch.Stop
  ' Posts the passed time to the test log
  Log.Message("Test1 finished. Execution time: " & StopWatch.ToString)

End Sub

DelphiScript

procedure Test();
var StopWatch;
begin
  StopWatch := HISUtils.StopWatch;
  // Starts the time counter
  StopWatch.Start;
  DoTest1;
  // Stops the time counter
  StopWatch.Stop;
  // Posts the passed time to the test log
  Log.Message('Test1 finished. Execution time: ' + StopWatch.ToString);

end;

C++Script, C#Script

function Test()
{
  var StopWatch;
  StopWatch = HISUtils["StopWatch"];
  // Starts the time counter
  StopWatch["Start"]();
  DoTest1();
  // Stops the time counter
  StopWatch["Stop"]();
  // Posts the passed time to the test log
  Log["Message"]("Test1 finished. Execution time: " + StopWatch["ToString"]());

}

See Also

HISUtils Object
Installing Extensions

Highlight search results