Additional and included files

Component Testing for C++

When creating a Component Testing test node for C++, the Component Testing wizard offers the following options for specifying dependencies of the source code under test:

  • Additional files

  • Included files

Additional Files

Additional source files are source files that are required by the test script, but not actually tested. For example, with Component Testing for C++, Visual C++ resource files can be compiled inside a test node by specifying them as additional files.

Additional header files (.h) are not handled in the same way as additional body files (.cc, .C, or .cpp):

  • Body files: With a body file, the Test Generation Wizard considers that the compiled file will be linked with your test program. This means that all defined variables and routines are considered as defined, and therefore not stubbed.

  • Header files: With a header file (a file containing only declarations), the Test Generation Wizard considers that all the entities declared in the source file itself (not in included files) are defined. Typically, you would use additional header files if you only have a .h file under test and a matching object file (.o or .obj), but not the actual source file (.cc, .C, or .cpp).

You can toggle a source file from under test to additional by changing the Instrumentation property in the Properties Window dialog box.

Additional directories are directories that are declared to only contain additional source files.

Functions which are not located in an additional file or in a tested file are simulated by Component Testing for C++.

Included Files

Included files are normal source files under test. However, instead of being compiled separately during the test, they are included and compiled with the C++ Test Driver script.

Header files are automatically considered as included files, even if they are not specified as such.

Source files under test should be specified as included when:

  • The file contains the class definition of a class you want to test

  • A function or a variable definition depends upon a type which is defined in the file under test itself

  • You need access in your test script to a static variable or function, defined in the file under test

In most cases, you do not have to specify files to be included. The Component Testing wizard automatically generates a warning message in the Output Window, when it detects files that should be specified as included files. If this occurs, rerun the Component Testing wizard, and select the files to be included in the Include source files section of the Advanced Options dialog box.

To specify included files while creating a test node:

  1. Select a valid C++ configuration and run the Component Testing wizard.

  2. On the Test Script Generation Settings page (Step 3/5), expand Components Under Test and <Test Name> . where <Test Name> is the name of the Test Node.

  3. Scroll down the list to Included Files, select the value field and click the '...' button to enter a list of files.

  4. Enter any other advanced settings and continue with the Component Testing wizard.

To specify additional files while creating a test node:

  1. Select a valid C++ configuration and run the Component Testing wizard.

  2. On the Test Script Generation Settings page (Step 3/5), select General and switch the Test Mode setting to Expert Mode.

  3. Expand Components Under Test and select Test Boundaries.

  4. Under Additional Files or Directories, select the value field and click the '...' button to enter a list of files or directories

  5. Enter any other advanced settings and continue with the Component Testing wizard.

Related Topics

Files and Classes Under Test | Component Testing Wizard | Advanced Options