next up previous
Next: References Up: PRIS Programmer's Handbook Previous: Function Documenation

Testing

A class is not finished until it is thoroughly tested and regression tests have been created.

We will have automated (regression/whitebox) testing of classes/components and libraries. Each .C file (corresponding to a component) will have test functions in it. These functions will be put at the bottom of the file, and will be registered with the testing system through the use of a macro. The test code will be ifdef'ed out if we are not compiling for testing, so that the code will not be include in the libraries. Each library will have a file called Test.C. This file will call the testing system which will run through all the tests. The Test.C file will also include all inter-component/library level testing. This means that in general, when changing code in a file all test code can be put directly in that file, so only one file will need to be changed. It also allows us to have more complicated regression testing put into a library level file.

An example of how testing code at the end of a file would look is:

#ifdef RI_TESTING
#include <Testing.H>

//
//   Test code goes here.
//   You can either have one testFunction for the file or one for each class.
//   The name of the test function should be test<Classname>

bool testFunction()
{
   // do test1, return false if fail.

   // do test2, return false if fail.

   return true;
}
   

#endif /* RI_TESTING */

Inside Test.C should appear the following macro, once for each of the the test functions that have been defined.

RI_TESTFUNCTION(test<Classname>);  // one for each testFunction

It is very important to have test functions that fully test all functionality, and that these test functions stay up to date. The final system will allow each library to be built and tested independently and automatically. This will help keep the entire system robust. It is easiest to copy a Test.C file from another directory and change the macros



Comments: Brian Edward Smits
Wed Apr 23 17:04:33 MDT 1997