Log.LockEvents Method

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

Description

By default, certain methods and actions post event messages to the test log. For instance, the Click action of onscreen objects inserts an "Executing Click" message with a reference to the source code line. The LockEvents method prevents these event messages, as well as those from the Log.Event method, from being posted to the test log.

LockEvents stays in effect until Log.UnlockEvents is called during the current run of the current test item, or execution of the current test item terminates.

When testing large applications, LockEvents and UnlockEvents can be used to avoid taking up too much memory for messages.

Declaration

Log.LockEvents(Count)

Count [in]    Optional    Integer Default value: 20   
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Count

Specifies the number of event messages that will be kept in a safety buffer (20 by default). If an error or warning occurs, the buffered messages will be posted to the log to help you pin down the source of the error or warning. To disable the buffer, set Count to 0.

Result Value

None.

Example

The code below disables posting unnecessary events and then enables posting them to post the desired event messages to the test log.

JavaScript, JScript

function LockEvents()
{
  // Disables posting events
  Log.LockEvents();
  
    // No event messages are posted to the test log
    Log.Event("This message won't be posted to the test log.");
  
  // Enables posting events
  Log.UnlockEvents();
  
  // Event messages are posted to the test log
  Log.Event("A test event message.");
}

Python

def LockEvents():
  # Disables posting events
  Log.LockEvents()
  # No event messages are posted to the test log
  Log.Event("This message won't be posted to the test log.")
  # Enables posting events
  Log.UnlockEvents()
  # Event messages are posted to the test log
  Log.Event("A test event message.")

VBScript

Sub LockEvents()

  ' Disables posting events
  Log.LockEvents()
  
    ' No event messages are posted to the test log
    Log.Event("This message won't be posted to the test log.")
  
  ' Enables posting events
  Log.UnlockEvents()
  
  ' Event messages are posted to the test log
  Log.Event("A test event message.")
   
End Sub

DelphiScript

function LockEvents;
begin

  // Disables posting events
  Log.LockEvents;
  
    // No event messages are posted to the test log
    Log.Event('This message won''t be posted to the test log.');
  
  // Enables posting events
  Log.UnlockEvents;
  
  // Event messages are posted to the test log
  Log.Event('A test event message.');

end;

C++Script, C#Script

function LockEvents()
{
  // Disables posting events
  Log["LockEvents"]();
  
    // No event messages are posted to the test log
    Log["Event"]("This message won't be posted to the test log.");
  
  // Enables posting events
  Log["UnlockEvents"]();
  
  // Event messages are posted to the test log
  Log["Event"]("A test event message.");
}

See Also

Test Results
UnlockEvents Method
Event Method

Highlight search results