This topic explains how to run a test from the C/C++test command line interface (cpptestcli), which is described in Command Line Interface (cli).

The Team Server features and functionality described in this section have been deprecated.

Sections include:

Prerequisites

The command line mode requires a command line interface license (available with C/C++test Automation Edition).

There are two command line interface licenses available for C/C++test:

  1. Extended Command Line Mode is provided in Automation Edition and available for Custom Editions.
  2. Desktop Command Line Mode is available for Custom Editions. The Desktop Command Line Mode provides similar functionality to the Extended Command Line Mode, except that parallel processing is limited to simultaneously executing 8 parallel threads for a given task (e.g. static analysis) in the Desktop Command Line Mode.

Setup Overview

Parasoft C/C++test Professional has two user modes: interactive desktop usage in the GUI and command line mode via the command line interface (CLI). The CLI interface is a standard feature of the Automation Edition. 

CLI mode is typically used to perform regular or continuous code analysis and test in conjunction with regular/continuous builds or as a part of an automatic regression test infrastructure. C/C++test CLI can be invoked on a full Visual Studio solution, or one or more projects or source files that are part of a solution. As part of the CLI execution, C/C++test can perform one or more of the following:

As part of the execution, C/C++test can use your SCM client (if supported) to automatically retrieve file modification information from the SCM system and generate tasks for specific individuals based on results of code analysis and executed tests.

Specific execution options for C/C++test are controlled via Test Configurations and Preferences.

Test Configurations can be sourced from the built in set, or created using C/C++test interactive mode in the GUI. We suggest using the built-in configurations as starting templates for customer-specific configurations.

Preferences can be configured from the C/C++test GUI. Most of the preference settings can also be supplied with a configuration file that is provided as a parameter to a CLI call. A table of the configuration file preference settings is available in Settings (Options) Files. C/C++test preferences set from the GUI are applied by default. These can be overridden — on an individual basis—by preference values contained in the configuration file used with a given run. This enables you to have a basic set of preferences configured for all CLI runs, and then vary individual settings as necessary by providing an additional configuration file for a specific run with a given Test Configuration. This can be useful, for example, to include different information in reports for different runs, or to change options for email distribution of reports, including report names, email headings, etc.

Step 1: Configure Preferences

C/C++test preferences are accessed through the Parasoft> Preferences menu. Start by configuring the following preferences:

Step 2: Customize Test Configurations

Create a custom Test Configuration as described in Configuring Test Configurations.

Step 3: Create a settings File

Create a settings file as described in Settings (Options) Files.

Step 4: Activate CLI in the Currently-Running Build System (e.g., batch script)

For example, your command line may resemble the following:

The reports will be sent after each batch run, and trend reports will be populated with data.

cli Usage

The general procedure for testing from the command line is as follows:

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.

C/C++test does perform static analysis and unit testing of instantiated function templates and instantiated members of class templates. See Support for C++ Template Functions for details.

  • C/C++test does not support file paths specified using Cygwin's "/cygdrive/DISK/PATH" format; instead, use the standard Windows path format.
  • Depending on the shell/console, backslashes in file paths should be escaped/doubled; e.g.,"C:\\MyLocation\\MyFile"
  • All backslashes in file paths must be escaped/doubled when used in options files (with the -settings option). Alternatively, you can use forward slashes; e.g., "C:/MyLocation/MyFile".

cli Invocation

The general form of invocation for cpptestcli is:

Typically, invocations follow this pattern:

If you want to exclude some files from analysis/testing (for instance, to prevent static analysis of automatically-generated files), you can indicate which project resources should not be tested as described in Excluding Project Resources from Testing. Perform this configuration in the GUI, then the settings will be applied for all tests on this project—from the GUI or from the command line.

cli Options

Available cpptestcli options are listed in the following tables.

General Options

Multiple settings files can be applied. The settings specified in an earlier file will be overwritten by a later file. For details on creating options files; see Settings (Options) Files.

Entries specified through the -settings option will always be overwritten by the -property option settings (regardless of the order in which these options are used in the command line).


Options for Testing Projects Available in the Visual Studio IDE

OptionPurposeNotes

-solution %SOLUTION_FILE%-solution %SOLUTION_FILE%Specifies the location of the solution file to use.

Specifies the location of the solution file to use.Specifies the location of the solution file to use.

N/AN/ASpecifies the location of the solution file to use.

-resource %RESOURCE%

Specifies the path to the workspace resource %RESOURCE% to test.

Use multiple times to specify multiple resources.

Use quotes when the resource path contains spaces or other non-alphanumeric characters.

If %RESOURCE% is a .properties file, the value corresponding to com.parasoft.xtest.checkers.resources will be interpreted as a colon(:)-separated list of resources. Only one properties file can be specified in this way. If %RESOURCE% is a .lst file, each line will be treated as a resource. If no resources are specified on the command line, the complete workspace will be tested.

For example, to test the ATM.cxx file in the C++test ATM example, you could use -resource "ATM/Source Files/ATM.cxx" (without the solution name)

or

-resource "Examples/ATM/Source Files/ATM.cxx" (with the solution name)

Other Examples:

-resource "MySolution/MyProject"

-resource "MySolution/MyProject/Source Files"

-resource "MySolution/MyProject/SourceFiles/MyClass.cpp"

-resource "c:\testedprojects.properties"

  • To see a list of valid command line options, enter for cpptestcli -help.
  • cpptestcli automatically emails designated group managers and architects a report that lists all team/project errors and identifies which developer is responsible for each error. If no errors are reported, reports will be sent unless the options file contains the report.mail.on.error.only=true option.
  • If the appropriate prerequisites are met, cpptestcli automatically emails each developer a report that contains only the errors/results related to his or her work. If no errors are reported for a particular developer, a report will not be emailed to that developer.

Settings (Options) Files

Settings files can be passed at the command line to control options for reporting, task assignment, licensing, and more. This allows you to:

You can create different options files for different projects, then use the -settings option to indicate which file should be used for the current command line test.

See Configuring Settings for information about settings files and the list of available settings.