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.

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.

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.
To access C++test’s full functionality, the machine where C++test is run must have the complete development environment and compiler tool chain.

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++test install directory>/<VS Version>/examples. This directory contains the source files and solution file for the Visual Studio environment.

 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.

C++test GUI

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 (a.k.a "the project tree") 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:

  1. If the Quality Tasks view is not already open, open it by choosing Parasoft> Show View> Quality Tasks.
  2. 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.

  • No labels