ToString Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The StopWatch.ToString method converts the number of milliseconds returned by the Split or Stop methods into a nicely formatted “hh:mm:ss.mmm” string.

Declaration

StopWatchObj.ToString()

StopWatchObj An expression, variable or parameter that specifies a reference to a StopWatch object
Result String

Applies To

The method is applied to the following object:

Result Value

The formatted string holding the passed time.

Example

The following code snippet starts a test and measures how much time has been spent on its 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

Reset Method
Split Method
Start Method
Stop Method

Highlight search results