Creating an C++ Component Test

Since you will be testing C++ code, the first order of business is to reselect the C++ TDP- based Configuration. Once done, you will follow virtually the same steps as you took for creation of a component testing test script for C and Ada. The difference? Accommodating the Test RealTime ability to implement assertion tests.

To create a C++ Component Testing test node

  1. Select the menu item Window->Close All (and close the Output Window at the bottom of the UI if you wish to free up additional space).

  2. In the toolbar dropdown list for Configurations, select the C++ TDP configuration you used in the Runtime Analysis exercises, thereby replacing the currently selected C TDP-based Configuration.

  3. On the toolbar, click the Start Page button.

  4. Select the Activities link on the left side of the Start Page.

  5. Select the Component Testing link in the center of the Start Page.

  6. In the window Application Files - Notice how all C++ source and header files of your project are already visible . No changes need to be made, so simply click the Next button.

  7. In the window Components Under Test, select the checkbox next to the reference to the PhoneNumber class. (Since a single C++ class can be defined in multiple files, classes are listed by the Wizard rather than any implementation reference. This also explains why the file in which a class is declared is listed in the File Name column - there is only one declaration, while definitions can occur across multiple files.) Click the Next button.

  8. In the Test Name field, enter the name PhoneNumber. Leave the default values and click the Next button.

  9. You should now be viewing the Summary window. Click the Next button.

The component testing wizard now analyzes the source code in PhoneNumber.cpp and PhoneNumber.h and creates a test for every class defined in the .cpp file.

  1. Click the Finish button.

  2. Select the menu item File->Save Project.

Notice now, in the Project Browser tab on the right-hand side of the screen, a C++ component testing node named PhoneNumber has been added to your project.