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:
C++test supports test cases debugging in two modes using:
Your development environment dictates which mode for test cases debugging should be selected. If you use Visual Studio IDE, then you should be able to select Visual Studio internal debugger (For details please refer to C++test plugin for Visual Studio documentation). If your development environment supports debugging directly in the Eclipse IDE then you should be able to select Eclipse internal debugger mode in your test configuration. You can still configure external debugger for test cases debugging if your development environment does not support debugging inside Eclipse.
For native development C++test supports:
For embedded development C++test supports:
C++test can be configured for two different modes of test cases debugging:
To enable debugging inside Eclipse IDE
In this mode C++test will use selected Eclipse Debug configuration to automate test exectable execution and entering the debugging mode inside IDE. For more details see Debugging in Eclipse Internal Debugger Mode.
To enable debugging with external debugger:
Enable the Use External debugger option.
In this mode some further configuration may be required depending on development environment. See Debugging Using External Debugger, mode for additional details.
You can use any of your existing Eclipse Debug configurations for test cases debugging. If you don't have a working Eclipse Debug configuration you will need to first prepare a configuration. For details on configuring Eclipse Debug configuration please refer to your development environment documentation.
It is recommended to verify that your Eclipse Debug configuration can be used for debugging your original project code before specifying it in C++test test configuration.
Use the "Standard Create Process Launcher" (standard CDT/Native development) |
C++test uses the following command-lines when launching the default debugger:
cmd.exe /C gdb -x %s
LC_ALL=C /usr/X11R6/bin/xterm -e gdb -x %s &
testrunner.debuggerCommandLine <COMMAND_LINE
>.Examples:
testrunner.debuggerCommandLine /usr/X11R6/bin/xterm -e xxgdb -x %s &
to use the xxgdb debugger.strunner.debuggerCommandLine ddd -x %s &
to use the ddd debugger.C++test support for debugging tests in embedded development environments is based on specific features of the environment. For more details see Debugging Test Cases.
This section covers debugging tests in native development environments. For information about debugging tests in embedded environments see Debugging Test Cases.
To execute a test withyour compiler’sdebugger:
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).
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.
Use standard debugger features to step through the test case.
|
|