This document begins by introducing you to C++test, and then provides lessons on how to use C++test to perform static analysis, unit testing, and runtime error detection on a sample application.
For all lessons:
• One of the supported compilers must be installed on a supported platform.
Some lessons have additional prerequisites, which are explained at the beginning of the lesson.
Proper Compiler Configuration is Critical In most cases, C++test needs to invoke the compiler and linker in order to perform static analysis and runtime testing tasks, which commonly involve preprocessing, compiling, and linking programs. |
The lessons in this tutorial demonstrate how to test the code for a sample ATM application. This application is a very simple model of an Automated Teller Machine. It allows access to bank accounts in order to deposit/withdraw funds and check balances.
The ATM application includes the following files:
The UML model of the application’s design is as follows:
The master source for the ATM project is located in <C++test install directory>/examples/ATM. This directory contains source files, a Makefile (using GNU gcc), and prepared Visual C++ projects. We will demonstrate how to create a C++test project for this source code in Tutorial - Creating a C++test Project.
Before starting the tutorial, make a copy of the original examples directory. This ensures that the original examples in the installation directory are kept intact as you modify the source files. |
The following image is the general view of the C++test standalone version. The standalone version and the Eclipse plugin version both have the same layout. Project files are displayed in the left pane. The right pane contains the editor. There are several tabs or views on the lower third of the screen; these tabs display information specifically related to each of the labeled tabs.
The Navigator (a.k.a. "the project tree") is where you can view projects and select the resource(s) that you want to test.
C++test allows you to configure the default layout of the user interface. This is achieved using perspectives and views.
To customize which "views" are available:
3. To open the Test Case Explorer view, choose Parasoft> Show View> Test Case Explorer.