Creating Process Dumps During a Test Run

Applies to TestComplete 15.45, last modified on December 01, 2022
Information in this topic applies to desktop applications only.

A dump is a copy of an application’s memory at a specific time. Dump files help developers track down the causes of application hangs, crashes and other issues.

You can configure TestComplete to create dumps automatically when an application hangs. You can also use test commands to create dumps at any time during test runs. For example, you can create dumps when your tested application is not closed properly, or when specific errors occur in it. This topic explains how to create dumps from tests.

Dump Types

TestComplete creates dumps in the minidump format. Developers can analyze minidumps with most debugging tools (for example, WinDbg from Debugging Tools for Windows, or Microsoft Visual Studio).

By default, minidumps include only the selected parts of a process’s memory. They are small, quick to create and are usually enough to debug common issues.

You can also create minidumps that include the entire memory of a process. Such minidumps, despite the name, can be large and may take some time to create, but can be more useful to the developers.

Methods Used to Create Dumps

To create a process dump, use the following methods of a Process object:

  • SaveDumpToFile - saves the process dump to a file.

  • SaveDumpToLog - saves the process dump to the project’s Log folder and adds the file link to the test log.

The FullMemory parameter of these methods controls whether to include the entire memory of the process in the dump.

Note: You can create dumps for running applications only. If your application crashes, you need to create a dump right before the test operation that causes the crash.

Creating Dumps From Keyword Tests

In keyword tests, you can call SaveDumpToLog or SaveDumpToFile by using the Call Object Method or Run Code Snippet operation.

Keyword test that creates a process dump

Creating Dumps From Scripts

The following script closes an application and waits for it to close for 1 minute. If the application does not close, the script calls the SaveDumpToLog method to create a dump and to add it to the test log.

JavaScript, JScript

function Test()
{
  var p = Sys.Process("MyApp");

  // Do something
  // ...

  p.Close();
  if (p.Exists)
  {
    Log.Error("Application hung on close.");
    p.SaveDumpToLog();
    p.Terminate();
  }
}

Python

def Test():
  p = Sys.Process("MyApp");

  # Do something
  # ...

  p.Close()
  if p.Exists:
    Log.Error("Application hung on close.")
    p.SaveDumpToLog()
    p.Terminate()

VBScript

Sub Test
  Dim p
  Set p = Sys.Process("MyApp")

  ' Do something
  ' ...

  Call p.Close()
  If p.Exists Then
    Call Log.Error("Application hung on close.")
    p.SaveDumpToLog
    p.Terminate
  End If
End Sub

DelphiScript

procedure Test;
var p;
begin
  p := Sys.Process('MyApp');

  // Do something
  // ...

  p.Close();
  if p.Exists then
  begin
    Log.Error('Application hung on close.');
    p.SaveDumpToLog;
    p.Terminate;
  end;
end;

C++Script, C#Script

function Test()
{
  var p = Sys["Process"]("MyApp");

  // Do something
  // ...

  p["Close"]();
  if (p["Exists"])
  {
    Log["Error"]("Application hung on close.");
    p["SaveDumpToLog"]();
    p["Terminate"]();
  }
}

See Also

Tracing Exceptions, Crashes and Freezes in Tested Applications
Handling Exceptions in Scripts

Highlight search results