This document begins by introducing you to C/C++test, and then provides lessons on how to use C/C++test to perform static analysis, unit testing, and runtime error detection on a sample application.
Prerequisites
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.
Sample ATM Application
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:
- Account.[hc]xx - Models a client account
- Bank.[hc]xx - Models a bank containing a set of accounts
- BaseDisplay.[hc]xx - Defines a simplistic user interface and provides a generic implementation
- ATM.[hc]xx - Client interface to ATM
The UML model of the application’s design is as follows:
The source files for the ATM project are within the Examples.sln file, which is located in <Visual Studio C/C++test install directory>/<VS Version>/examples. This directory contains the source files and solution file for the Visual Studio environment.
C/C++test GUI
C/C++test functionality is integrated into the Visual Studio environment via a Parasoft menu, toolbar buttons, context-specific shortcut (right-click) menus, and special tabs that we call "views." These include the Quality Tasks view (where test results are reported), the Coverage view (where test coverage metrics are reported), and the Suppressions view (where you can view and manage static analysis suppressions). To display a view that is "hidden," choose Parasoft> Show View> [desired view].
The Visual Studio Solution Explorer is where you can view projects and select the resource(s) that you want to test.
Exercise 1: Configuring Views
To customize which "views" are available:- If the Quality Tasks view is not already open, open it by choosing Parasoft> Show View> Quality Tasks.
- To open the Coverage view, choose Parasoft> Show View> Coverage.
3. To open the Test Case Explorer view, choose Parasoft> Show View> Test Case Explorer.