Coverage Testing

Applies to TestComplete 15.70, last modified on December 17, 2024
Information in this topic applies to desktop applications only.

When testing applications, QA engineers and testers need to know which application areas are covered by tests. Knowing the test coverage is critical for thorough application testing and thus, it is critical for application quality.

The code coverage functionality is not provided by TestComplete, it is provided by another SmartBear product - AQtime. AQtime includes about two dozen various productivity tools - profilers and panels - that let you trace application performance, check test coverage, search for memory and resource leaks, obtain exception call stacks and perform other tasks that concern checking and improving application quality. For more information on AQtime, see Integration With AQtime.

To use AQtime, TestComplete must be launched with administrator permissions.

Performing Coverage Tests Using AQtime

TestComplete can be tightly integrated with AQtime, so you can use AQtime’s coverage functionality to determine the coverage of your TestComplete tests. A typical procedure includes the following steps:

  1. Install AQtime 4 - 8 on your computer.

    Note: The described procedure works for AQtime version 4 - 8. If you have an earlier version of AQtime, you can control AQtime runs only from scripts.
  2. Prepare your application for AQtime. For more information on how to do this, see AQtime documentation.

  3. (Optional) If needed, create an AQtime project for your application and tune the project settings.

  4. Add the Tested Applications project item to your TestComplete project, if it has not been added yet.

  5. Add your tested application to the Tested Applications list. See Adding Tested Applications for more information on how to do this.

  6. Modify the application's launch parameters:

    • Select your application in the TestedApps editor.

    • Choose Profile in the Run Mode drop-down list.

    • TestComplete will launch AQtime in the background to retrieve a list of available profilers (if the list was retrieved earlier, TestComplete will not launch AQtime. To refresh the list, press Get profilers).

      Select the desired profiler and specify run settings. If you use AQtime 6 - 8, you can choose either the Coverage, or the Light Coverage profiler (to learn the difference between these profilers, see the AQtime documentation). If you use an earlier version of AQtime, select the Coverage profiler.

      If you want to review detailed profiling results in AQtime, you need to specify the AQtime project. If you do not specify the AQtime project, AQtime will create a temporary project that will be deleted after profiling is over.
    • Save the changes.

  7. Command TestComplete to launch your application, TestComplete will run AQtime and start the specified coverage profiler.

  8. Run your tests created for the application. AQtime will profile the application while TestComplete is simulating user actions on it.

  9. After the profiling is over (when you close the application or stop the profiling process manually), AQtime generates profiling results.

Note: When the tested application is launched in the Profile mode by using the TestedApp.Run method, the method returns the AQtime object rather than the Process object. To simulate user actions over the profiled application, obtain the application process by using the Sys.Process or Sys.WaitProcess method.

Note that you can also setup the parameters of the Profile run mode from tests. To do this, you use properties of the TestedAppProfileParams object, which you can obtain through the TestedApp.Params.ProfileParams property. The following code demonstrates how you can set up the parameters:

JavaScript, JScript

// Obtain the tested application
var MyApp = TestedApps.MyTestedApp;

// Specify the run mode parameters
MyApp.Params.ProfileParams.AQtimeVersion = 8;
MyApp.Params.ProfileParams.ProfilerName = "Coverage Profiler";
MyApp.Params.ProfileParams.RunMode = "Normal";
MyApp.Params.ProfileParams.UseProject = true;
MyApp.Params.ProfileParams.ProjectFileName = "C:\\My Projects\\My project.aqt";
MyApp.Params.ProfileParams.OverrideProfiler = true;

// Activate the Profile run mode
MyApp.Params.ProfileParams.Activate();

// Run the application
MyApp.Run();

// Simulate user actions on the tested application
// …

Python

# Obtain the tested application
MyApp = TestedApps.MyTestedApp

# Specify the run mode parameters
MyApp.Params.ProfileParams.AQtimeVersion = 8
MyApp.Params.ProfileParams.ProfilerName = "Coverage Profiler"
MyApp.Params.ProfileParams.RunMode = "Normal"
MyApp.Params.ProfileParams.UseProject = True
MyApp.Params.ProfileParams.ProjectFileName = "C:\\My Projects\\My project.aqt"
MyApp.Params.ProfileParams.OverrideProfiler = True

# Activate the Profile run mode
MyApp.Params.ProfileParams.Activate()

# Run the application
MyApp.Run()

# Simulate user actions on the tested application
...

VBScript

' Obtain the tested application
Set MyApp = TestedApps.MyTestedApp

' Specify the run mode parameters
MyApp.Params.ProfileParams.AQtimeVersion = 8
MyApp.Params.ProfileParams.ProfilerName = "Coverage Profiler"
MyApp.Params.ProfileParams.RunMode = "Normal"
MyApp.Params.ProfileParams.UseProject = True
MyApp.Params.ProfileParams.ProjectFileName = "C:\My Projects\My project.aqt"
MyApp.Params.ProfileParams.OverrideProfiler = True

' Activate the Profile run mode
MyApp.Params.ProfileParams.Activate

' Run the application
MyApp.Run

' Simulate user actions on the tested application
' …

DelphiScript

var
  MyApp : OleVariant;
begin
  // Obtain the tested application
  MyApp := TestedApps.MyTestedApp;

  // Specify the run mode parameters
  MyApp.Params.ProfileParams.AQtimeVersion := 8;
  MyApp.Params.ProfileParams.ProfilerName := 'Coverage Profiler';
  MyApp.Params.ProfileParams.RunMode := 'Normal';
  MyApp.Params.ProfileParams.UseProject := true;
  MyApp.Params.ProfileParams.ProjectFileName := 'C:\My Projects\My project.aqt';
  MyApp.Params.ProfileParams.OverrideProfiler := true;

  // Activate the Profile run mode
  MyApp.Params.ProfileParams.Activate();

  // Runs the application
  MyApp.Run();

  // Simulate user actions on the tested application
  // …

end;

C++Script, C#Script

// Obtain the tested application
var MyApp = TestedApps["MyTestedApp"];

// Specify the run mode parameters
MyApp["Params"]["ProfileParams"]["AQtimeVersion"] = 8;
MyApp["Params"]["ProfileParams"]["ProfilerName"] = "Coverage Profiler";
MyApp["Params"]["ProfileParams"]["RunMode"] = "Normal";
MyApp["Params"]["ProfileParams"]["UseProject"] = true;
MyApp["Params"]["ProfileParams"]["ProjectFileName"] = "C:\\My Projects\\My project.aqt";
MyApp["Params"]["ProfileParams"]["OverrideProfiler"] = true;

// Activates the Profile run mode
MyApp["Params"]["ProfileParams"]["Activate"]();
 
// Run the application
MyApp["Run"]();

// Simulate user actions on the tested application
// …

You can also launch profiling and control AQtime from scripts using special program objects. Using these objects you can automate AQtime ver. 4 - 8 as well as earlier versions. For more information on this, see Integration With AQtime.

Checking Coverage Tests Results

At the end of the test run, you will get two result sets: one in AQtime and another in TestComplete. You can export brief profiling results to XML files and post links to the files to the test log. View the brief profiling results to determine the test coverage. To obtain detailed results (for instance, to determine which routines and source lines of your application were executed during the test), view the results in AQtime.

See Also

AQtime
Integration With AQtime

Highlight search results