This topic explains the general procedure for running tests from the C/C++test Professional GUI.
Sections include:
Prerequisites
- Before you can test code with C/C++test, it must be added to a Visual Studio project; see Creating a Project.
- Before you perform the initial test, you need to review and project options then modify them if needed. For details on how to do this, see Setting Project and File Options.
- We recommend that you prepare a customized test configuration before you perform tests; see C++test Configuration Overview and Configuring Test Configurations and Rules for Policies.
If you want to exclude designated project resources from the test or test only a designated subset of project resources, you must indicate that before starting the test. See Testing a User-Defined Set of Resources for details.
Testing Headers
C/C++test does not directly test headers unless they are included by a source file under test.
See How do I analyze header files/what files are analyzed? for details.
Testing Template Functions
C/C++test does perform static analysis and unit testing of instantiated function templates and instantiated members of class templates.
See Support for Template Functions for details.
Running a Test
C/C++test can perform a variety of tasks, from static analysis, to unit/regression test generation and execution, to exception finding. To start using C/C++test to achieve your goals, you run a test based on a default or custom test scenario, which defines the precise nature and scope of C/C++test's analysis. These test scenarios are called "test configurations," and they define settings such as test scope, static analysis, test case generation, and test case execution settings.
All preconfigured test configurations are described in Built-in Test Configurations. You can create a custom test configruation; see Configuring Test Configurations and Rules for Policies.
The general procedure for testing from the GUI is as follows:
- In the Eclipse C/C++ Projects view (a.k.a. "the project tree"), select the resource(s) that you want to test.You can use Ctrl + click or Shift + click to select multiple resources.
- In the Visual Studio Solution Explorer (a.k.a "the project tree"), select the resource(s) that you want to test.You can use Ctrl + click or Shift + click to select multiple resources.
Running a Test Configuration
- Choose the appropriate Test Configuration from the Test Using section of the Test button’s pull-down menu.
- Choose the appropriate Test Configuration from the Parasoft> Test Using menu in the menu bar.
- Choose the appropriate Test Configuration from the Parasoft Test History menu in the menu bar. Note that this menu contains only the most recently-run Test Configurations.
- Right-click the selection, then choose the appropriate Test Configuration from the Test Using shortcut menu.
- Right-click the selection, then choose the appropriate Test Configuration from the Test History shortcut menu.
"Grayed-Out" Test Configurations = Incompatible Test Configurations
If a Test Configuration is "grayed out," this indicated that it was created with an incompatible version of C/C++test, and cannot be applied with the current version.
For Running the #1 Favorite Test Configuration
- Click the Test button in the toolbar.
- Choose Parasoft> Test Using> [Favorite Configuration] from the menu bar.
- Right-click the resource, then choose [product_name]> Test Using [Favorite Configuration] from the shortcut menu.
For Running Other Favorite Test Configurations
- Click the appropriate toolbar button.
- Use the applicable keyboard shortcut. To see a list of available shortcuts, press Shift + F9 (for Eclipse) or Ctrl+Alt+F9 (for Visual Studio).
C/C++test will then run the test scenario defined by the selected test configuration.
Unit Testing Procedure
For unit testing, we recommend that you run multiple test configurations in the following order:
- Generate Unit Tests
- Generate Stubs
- Build Test Executable
- Run Unit Tests
See Generating Test Cases for Regression Testing and Exception Finding and Executing Test Cases for details.
Reviewing Results
Test progress and results summaries will be reported in the Test Progress tab that C/C++test opens when it starts the test. Detailed results will be reported in the Quality Tasks view, which can be opened by choosing Parasoft> Show View> Quality Tasks. Drill down to see details about the test findings.
See Reviewing Results for details about the procedure for reviewing results.
Fine-Tuning Test Settings
To change test settings — such as what rules are checked, how test cases are generated, whether coverage is tracked, etc.— edit an existing Test Configuration or create a new one, then run a test using the modified/new Test Configuration. Test Configurations and all related parameters can be viewed, edited, and modified in the Test Configurations dialog. To open this dialog, choose Parasoft> Test Configurations from the menu bar.
See the Configuring Test Configurations and Rules for Policies for details about configuring test configurations.
Testing a User-Defined Set of Resources
To test a user-defined set of resources in C/C++test:
- In the project tree, use Ctrl+ click or Shift + click to highlight the items that represent the resources you want to test, then start the test.
- Configure your preferred Test Configuration to limit the files and code to be analyzed via the controls available in the Scope tab. For details, see Scope Tab Settings: Defining What Code is Tested.
Excluding Project Resources from Testing
If you do not want all files to be analyzed/tested (for instance, to prevent the checking of automatically generated files), you can exclude project resources from testing. To indicate which project resources should not be tested:
- In the project tree, right-click the project that contains the files that you want to be excluded.
Choose Parasoft> Properties from the shortcut menu, then select the Scope Settings category in the left pane.
Use the available controls to indicate which specific resources you want to skip and/or exclusion patterns that specify the set of resources you want to skip.
- To exclude specific files or directories, click Add Resources, then select the resource(s) that should not be tested.
- To specify an exclusion pattern that indicates a set of resources you want to skip, click Add Pattern, then enter a pattern.
- The pattern matching is based on Ant/Nant-style wild cards: '?' matches a single character, '*' matches any string (but does not match across path segments), and '**' matches any sequence of path segments.
- You can use the file separators / and \ interchangeably.
- Pattern-matching is case-insensitive.
- The paths specified are relative to the project.
- Examples:
**\Generated*.c
- Excludes all C files that 1) are in any project directory and 2) have a name starting withGenerated
.**\*.designer.c
- Excludes all C files that 1) are in any project directory and 2) havedesigner.c
as the final part of the name.biz\Test*.c
- Excludes all C files that 1) are in the biz directory and 2) have a name starting withTest
. It will not exclude such files if they are located in subdirectories ofbiz
.biz\**\Test*.c
- Excludes all C files that 1) are in thebiz
directory and its subdirectories and 2) have a name starting withTest
.
- Examples:
4. Click OK or Apply.
If you share your project via source control, these preferences will be shared across the team (preferences are saved in the .parasoft
project definition file).