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 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.

C++test GUI

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.



Exercise 1: Configuring and Customizing Perspectives and Views

C++test allows you to configure the default layout of the user interface.  This is achieved using perspectives and views. 

  1. Choose Window> Open Perspective> Other. The Open Perspective dialog will open.
  2. From the Open Perspective dialog, select Parasoft C++test, then click OK. Following these steps will change the user interface. The view tabs at the bottom third of the screen can also be manipulated separately for each perspective. Specifically, they can be closed or reopened when desired.


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