Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space CPPTDESKDEV and version 10.4.2

This topic explains how to step through C++test test cases with a debugger to better examine the code's internal state during a given test. For example, you might want to debug test cases to learn more about how C++test obtained an unexpected outcome, or to determine why a test case failed. You do not need to manually add breakpoints to the code. C++test will automatically set the breakpoints at the beginning of each test case that you select for execution.You can execute tests with your compiler’s debugger, or debug directly in the Eclipse IDE (according to an Eclipse Debug Configuration you have configured). 

Sections include:

Table of Contents
maxLevel1

...

  1. Prepare a "Debug Unit Tests" Test Configuration.
  2. Run your preferred "Debug Unit Tests" Test Configuration as follows:
    1. Select test case(s) that you want to debug in one of the following ways:
      • Select the test case in the Test Case Explorer.
      • Select the test case function name in the code editor.

      • Select the test case function in the Project Explorer (not available for CDT 4.x+ Managed C/C++ projects).

    2. Launch your preferred "Debug Unit Tests" Test Configuration. For example, right-click the selection, then use the Parasoft shortcut menu to run the preferred Test Configuration. C++test will then launch appropriate debugger and automatically set the break-points at the beginning of each selected test case function.

      Info
      iconfalse

      Debugging in Microsoft Visual Studio

      When using Microsoft Visual Studio 6 as the debugger environment, perform the following steps after the Visual Studio GUI opens:

    3. Select the test process in the Attach to Process dialog and click OK.
    4. Click Break Execution  (or choose Debug> Break from the menu bar).
    5. Press the F5  (Go) button. The debugger will break at the beginning of the

      test case function

      .

      When using Microsoft Visual Studio 2003 with Service Pack 1 as the debugger environment, perform the following steps after the Visual Studio GUI opens:

      • Select the test process in the Processes dialog and click Attach.
      • Confirm the application type (Native) by clicking OK in the Attach to Process dialog.
      • Close the Processes dialog.
      For other versions of Microsoft Visual Studio, no extra steps are needed

      .


  3. Use standard debugger features to step through the test case.

    Note
    iconfalse

    • Before you use your debugger with C++test, ensure that your debugger executable is included in the $PATH environmental variable.

    • The debugger will be activated only if the debugging Test Configuration is run on a selection of one or more test cases. Otherwise, the following warning will appear in the console output and the execution will continue without debugging:
      Warning: debugger will not be activated - no valid breakpoints found. Select (test case) function definitions to set breakpoints.

    Tip
    titleUse the Standard Create Process Launcher


    For the debug configurations, we recommend using the Standard Create Process Launcher (modified via Windows> Preferences> Run/Debug> Default Launchers) because this allows you to select a debugger. The default Eclipse launcher (GDB DSF) Create Process Launcher does not provide this option.