Project #1 - Single-User Test Harness

Version 1.0,
Due Date: 12:00 am, Sunday, Wk2

Purpose:

Developing software consisting of multiple packages1 requires frequent testing. If the software has complex features, we want to build it incrementally. First design and implement a very basic core with a small number of packages, then add features one-at-a-time by adding new packages, or adding a few lines of code to an existing package. Each time we add new functionality, we build and test. That way, if additions break existing code, we know where to look, e.g., in the newly added few lines of code. A test harness allows us to use that incremental process efficiently.
A test harness should allow us to define and aggregate many small tests, each of which run with exception handling and results logging. Our goal is to do that without littering our code with many try-catch blocks and many logging statements. The technique we use to do that is to define, in the test harness, an execution function that accepts a callable test object2 - function pointer, functor, or lambda - and invokes the object within the scope of a try block. A catch clause displays exceptions and returns false to indicate test failure. Otherwise the executor returns the test predicate returned by the test object, e.g., true or false for pass or fail.
The test executor also provides results logging with predefined messages. Your test harness should define several levels of loggin, e.g., just pass or fail, or more detailed, test-specific messages, or very detailed debugging messages, which display a time-date stamp and the values of key test-defined variables.
The test harness provides a mechanism to link any number of tests into a test sequence. Typically, during development, we keep adding tests for each new feature, and can rerun tests just for that feature, or all the tests of all the features, to insure that the new addition didn't break existing functionality.

Requirements:

Your Single-User Test Harness:
  1. Shall be prepared using the latest version of Visual Studio, and written in the standard C++ programming language, using the standard C++ libraries.
  2. Shall provide a TestHarness class that defines an executor method, accepting any callable object that accepts no arguments3 and returns a bool predicate to indicate success or failure.
  3. The executor method Shall invoke a passed callable object in the scope of a try block. If exceptions are thrown, the catch block you define for this method shall log test failure and the contents of the exception message.
  4. Shall support linking any number of callable objects for execution, and shall provide a mechanism for executing that sequence.
  5. Shall provide a multi-level logging mechanism, intended to show:
    • just pass-fail status
    • application specific messages for pass and fail, along with the result
    • detailed debugging output that includes, on failure, values of application specific variables, and an optional time-date stamp
  6. Shall provide a sequence of tests demonstrating all the features of your TestHarness.

  1. In C++, a package is consists of two files - a header file that has:
    • A prologue, consisting of comments that describe the package and its operations, required files, and maintenance history.
    • Declarations of one or more classes.
    • Definitions of inline functions and template methods.
    and an implementation file that has:
    • Definitions of all methods declared, but not defined, in the header.
    • A test stub for construction tests.
  2. A callable object is an object that can be invoked as if it were a function. These will be described in detail in several of the lectures, but you can get a quick overview by looking at the course Summary
  3. You can provide arguments for the execution as member data of a functor, or as data captured by a lambda.

What you need to know:

In order to successfully meet these requirements you will need to know:
  1. The definition of the term package and have looked carefully at a few examples.
  2. How to use basic features of the C++ language.
  3. How to organize and prepare a multi-package Visual Studio solution.