Clone wiki

ScriptExtensions / Indicator Timer

Indicator Timer

This script extension was developed in response to a request for an Indicator Timer on the TestComplete new ideas area. This object is presented as is with the understanding that the developer is not liable for any damages incurred in using this extension.

Abstract

Properties

  • projectStartTime - Read/Write - This is used for storing and making available the timestamp when the test project was started
  • projectElapsedTime - Read Only - This is updated by the extension when the runtime object's method is executed to keep an up to date timestamp of how long the test was running

Methods

  • updateIndicatorTimer - This method is intended to be used within a Timer object created in a TestComplete project. Everytime the timer fires, this method will update the indicatore with a formated version of projectElapsedTime

Implementation

There are a few things that need to be done to implement the timer in a project

First, in your project, create a simple wrapper function somewhere to call the timer object method. The reason being is that timer objects cannot call script extension methods directly. Something like this:

function timerExecution() {
    IndicatorTimer.updateIndicatorTimer();
}

Next, at the beginning of your project, somewhere that will be executed when you start your project run, make the following call:

IndicatorTimer.projectStartTime = aqDateTime.Now();

This initializes the timer at the start of your project run so we can get the elapsed time.

Then, create your timer:

    myTimer = Utils.Timers.Add(1000, 'Unit1.timerExecution', true);

And boom... there ya go... every second now, the Indicator will update to include a formatted text showing hours, minutes, and seconds of elapsed time.

You can even include at the end of your project a line like:

Log.Message('Overall elapsed time = ' + aqConvert.DateTimeToFormatStr(IndicatorTimer.projectElapsedTime, '[%H:%M:%S]'));

Click here to download the TCX file

Updated