Regression testing

[Home]   [Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

 

Available Now

Search

Google
 

Search WWW             

Search delphiforfun.org

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Help support DFF

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

 

Google
 

Search WWW

Search delphiforfun.org

 

 

Problem Description

Here's a class TRegress, which provides a framework for building regression tests for specific programs.  Included is the program that motivated the new class, BigIntsTest builds and tests case files for our TInteger class.   TInteger does  arithmetic for arbitrarily long integers.

Background & Techniques

Regression testing is a major part of quality control for commercial software projects.  Introducing a new bug while fixing an old one is a common occurrence in programming.  Regression testing, sometimes called "back testing",  reruns inputs that are known to run successfully to make sure that it still produces the same output, or at least that any differences represent improvements.

Our TInteger unit has gained popularity here at DFF and among users who need to do large integer arithmetic.   Several contributors have worked at adding functions and improving the speed of the component which has put me in the role of quality control analyst, a job I managed to avoid during my professional career.  But it did provide an excuse to create this initial attempt at a regression testing control.  

The TRegress class contains the methods to assist in building or retrieving
cases from a file.   A calling program will be required for each specific application.  The case file is a plain text file containing nine lines per case as defined by the following TOprec record definition: (All variables are in text string. format.)

  • CaseID: Case identifier.
  • Funcstr: A description of the operations.
  • OpCode: Numeric indicator of the operation performed.
  • Op1,Op2, Op3: Up to 3 input operands
  • Result1, Result2: 1 or 2 results; For Boolean results, 1=true, 0=false.
  • RunMuSecs: Execution time in microseconds.

Here are the main methods contained in the class: 

Create constructor takes three parameters from the calling program:

  • NewOnLoadrec: Address of an optional function in the user program called by TRegress when a case is to be retrieved and tested by GetNextrec. It gives the user a chance to move the input operands to his
    edit areas. Calling sequence is defined in TEventRec.   Value may be Nil if not necessary in calling program
  • NewOnEvaluate: Address of a user function called by GetNextrec and by Saverec functions to evaluate the current case. Any unused TOprec
    fields are set to 0.
  • NewMemo: Address of a TMemo used by TRegress to display results.

Procedure Reset opens process a case file based on the NewMode value passed:

  • Newmode  opens a new file for adding cases
    Newmode=Append opens an existing file at the end of existing case for adding new cases.  New cases are numbered  beginning with the number of cases in the file + 1.   
  • NewMode=Read opens a file for reading to comparison with new results
  • Newmode=None just closes any open file. 
  • Newmode=Renumber is provide a handy way to update a case file with new case numbers, descriptions, results, and run times base on the Op code and input field found on the input file.  

Function GetNextrec returns a TOprec record with the next case.  If no more cases are found, function returns false, otherwise true.

Procedure Saverec saves a case passed in a TOprec when mode is Write or Append.  Saverec calls the OnEvaluate function to fill in the results fields, and optionally run time microseconds.  If OnEvaluate does not fill in run time, Saverec will do it. .       

The included demo program,  BigIntsRegrTest,  contains most of the arithmetic functions of TInteger, including a couple with Boolean results.    An executable version compiled with an older version of TInteger of UBigIntsV2, the unit containing the TInteger class,  is included in the zip file for constructing or adding to case files.  The current version included in the DFFLibV03 library as of September 8 is included here so that those not otherwise requiring the library file, can compile and see typical old vs. new version results.

    

Running/Exploring the Program 

Suggestions for Further Explorations

x

 

Original Date: September 7, 2005

Modified: February 01, 2007

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2008, Gary Darby    All rights reserved.