TestingLite Library User Manual

Version 1.12

 

 

This program is free software; you can redistribute it and/or

modify it under the terms of the GNU General Public License

as published by the Free Software Foundation; either version 2

of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

 

The complete source code for the TestingLite library is

available at CommonTest.SourceForge.net. The author may

be contacted at americ@Users.SourceForge.net.

Copyright (C) 2000.

 

 

 

TestingLite Library User Manual *

Introduction *

Specifications of Library *

Quick Start *

Slow Start *

Building With TestingLite *

Using TestingLite *

Trouble Shooting *

License *

Adding To The Library *

Credits *

 

 

Introduction

The TestingLite Library provides a small set of test execution tools and test building tools for quickly setting up a program to run automated tests.

Specifications of Library

The TestingLite Library

 

Quick Start

Go to the samples subdirectory of the installation and pick a sample based on the kind of testing you need to do. Currently the choices are:

 

Slow Start

Building With TestingLite

The installation for the TestingLite library contains two subdirectories required for setting up an application that uses the library:

The include path must be added to your application’s preprocessor include path and the lib path must be added to your application’s linker input path. The individual .lib filenames are not important, so don’t add them to the compiler’s link settings. Thanks to a special #pragma statement used by TestingLite the correct .lib file will automatically be linked into your program.

 

Using TestingLite

The TestingLite library contains the following categories of functionality:

  1. Test Running – command-line parsing and invocation of user-defined test functions
  2. Memory Leak Detection – sets up the Microsoft Run-Time library for memory leak detection
  3. Test Writing Utilities – lots of powerful goodies for making tests
  4. Logging – class to record data to a text file

Test Running

The TestingLite library provides a set of macros for building a "TestMap". The TestMap can then be passed to the TestMain() function, along with the command-line arguments from the program’s main() routine, to invoke individual tests or groups of tests.

TestMap Macros:

TEST_MAP( mapName )

TEST_MAP_BEGIN( mapName )

TEST_MAP_END

TEST_MAP_ENTRY( testName )

TEST_MAP_SUITE_BEGIN( suiteName )

TEST_MAP_SUITE_END

Simple Example TestMap:

TEST_MAP_BEGIN( FooTest )

TEST_MAP_ENTRY( FooTestFunction )

TEST_MAP_END

What does this do?

void FooTestFunction_test(void)

return TestMain( argc, argv, TEST_MAP( FooTest ) );

What does TestMain() do?

Example Command-Line for FooTest:

footest /p FooTestFunction

This command causes the FooTestFunction_test() routine to be called, and when it completes, a prompt is given to the user prior to exiting.

What About Test Suites?

A test suite is a named collection of tests. TestingLite’s idea of a test suite is pretty simple. It requires the suite to be delimited in the TestMap using the following TEST_MAP_SUITE_BEGIN() and TEST_MAP_SUITE_END macros. The suite name used in the ..._BEGIN() macro can be any string that won’t goof up the command-line. Basically, stick to letters, numbers, and punctuation like underscores and colons.

One nice way of setting up test suites is to make each one a C++ namespace. This way, the list of tests viewable with the /l option always looks like a list of C++ functions.

Test Suite Example TestMap:

TEST_MAP_BEGIN( FooTest )

TEST_MAP_SUITE_BEGIN( SimpleTests )

TEST_MAP_ENTRY( SimpleTests::FooTestFunction1 )

TEST_MAP_ENTRY( SimpleTests::FooTestFunction2 )

TEST_MAP_SUITE_END

TEST_MAP_ENTRY( FooSmokeTest )

TEST_MAP_SUITE_BEGIN( ComplexTests )

TEST_MAP_ENTRY( ComplexTests::FooTestFunction1 )

TEST_MAP_SUITE_END

TEST_MAP_END

What does this do?

void SimpleTests::FooTestFunction1_test(void)

void SimpleTests::FooTestFunction2_test(void)

void FooSmokeTest_test(void)

void ComplexTests::FooTestFunction1_test(void)

SimpleTests::FooTestFunction1

SimpleTests::FooTestFunction2

FooSmokeTest

ComplexTests::FooTestFunction1

SimpleTests

ComplexTests

More on TestSuites:

 

Memory Leak Detection

The header file MemLeakDetect.h can be included into a single source file in your project, if you are NOT using MFC, in order to turn on the C RunTime Library’s memory leak detection feature.

 

Test Writing Utilities

TestingLite consists of the following categories of Test Writing Utilities:

  1. File Comparison
  1. File Manipulation (See FileTools.h)
  2. Directory Manipulation (See DirTools.h)
  3. Process Launching (See ProcessTools.h)
  4. Stream Manipulation (See StreamRedirectJanitors.h)

The TestingLite Library contains some very advanced file comparison features for performing Regression Tests. This part of the library is designed for tests that generate output files such that the output file for one run of the test can be compared to the output file from that last "correct" build of the software to determine if the software has Regressed. When software Regresses it loses features and/or gains bugs.

The Regression Comparison system centers on the FileRegCompare.h header. It declares the CFileRegCompare class. This class allows clients to plug-in custom facilities for doing the following:

To use the Regression Comparison system you must do the following:

assert( CFileRegCompare().Compare( strRefPath, strTempPath ) );

Where strRefPath is the filename of the "correct" output file, and strTempPath is the filename of the "actual" output file for this test run.

See the ProcessTest sample for an example of using the Regression Comparison system.

 

Logging

The Logger.h header includes a simple class for logging text to a disk file.

Samples

Currently the TestingLite library has two sample programs. They are in the samples directory under the release.

Sample

Description

Demonstrates

ClassTest

tests a simple time-of-day storage class

  • Basics of testing linked-in software

ProcessTest

tests a standalone program for searching a file.

NOTE: this sample requires WinDiff to be installed.

  • Testing of software run as a process
  • Regression File Comparison
  • Logging to a file

 

 

Trouble Shooting

<no problems known at this time>

 

License

The TestingLite library is released under the GPL. A copy of the GPL should have been received with the TestingLite library, and this document. The file’s name is probably GPL.txt. The license is also available at http://www.gnu.org/copyleft/gpl.txt .

To summarize it, you can modify and redistribute this software as long as you give credit to the authors, and you don’t charge for it.

 

Adding To The Library

If you have ideas for corrections, enhancements, etc. for the library please send them to the authors (see the Credits seciont). If you have already made changes to the library that you think are globally useful, send them in and they may be added to the library in future releases (Wow! that sounded really professional).

 

Credits

The TestingLite Library was written by Eric Runquist. The author may be contacted at americ@users.sourceforge.net.

This software was developed with the generous support of Pyramid Solutions, Inc. (www.pyrasol.com).