SimpleTest v1.0 

 The Simple Development Library regression testing framework 

Project: the Simple Development Library.

Table of contents

1. Package description
   1.1 Overview
   1.2 Usage
   1.3 Examples
   1.4 History
   1.5 Copyright
2. Package public API
   2.1 Types
      2.1.1 testtag
      2.1.2 testcriteria
   2.2 Options
      2.2.1 -store
   2.3 Namespaces
   2.4 Commands
      2.4.1 ::Simple::Test::cget ?-store?
      2.4.2 ::Simple::Test::configure ?-store list?
      2.4.3 ::Simple::Test::flags
      2.4.4 ::Simple::Test::initialize
      2.4.5 ::Simple::Test::reset
      2.4.6 ::Simple::Test::results
      2.4.7 ::Simple::Test::set-test-criteria testCriteria
      2.4.8 ::Simple::Test::shutdown
      2.4.9 ::Simple::Test::statistics
      2.4.10 test-case tag title ?-regexp? ?-prerequisites script-list? ?-dependencies testtag-list? ?-setup script? ?-script script? ?-cleanup script? ?-output string? ?-error string? ?-return string?
   2.5 Errors
      2.5.1 ::Simple::Test::ENVIRONMENT-NOT-INITIALIZED
      2.5.2 ::Simple::Test::NO-SCRIPT-FLAG
      2.5.3 ::Simple::Test::RETURN-AND-ERROR-FLAGS
      2.5.4 ::Simple::Test::BAD-SET-OF-RANGES
      2.5.5 ::Simple::Test::BAD-FLAG-TO-STORE
3. Package further information
   3.1 Details
   3.2 Todo
4. Package command details
   4.1 ::Simple::Test::cget ?-store?
      4.1.1 Command description
      4.1.2 Command public API
   4.2 ::Simple::Test::configure ?-store list?
      4.2.1 Command description
      4.2.2 Command public API
   4.3 ::Simple::Test::flags
      4.3.1 Command description
         4.3.1.1 Overview
      4.3.2 Command public API
   4.4 ::Simple::Test::initialize
      4.4.1 Command description
      4.4.2 Command public API
      4.4.3 Command further information
         4.4.3.1 Remarks
   4.5 ::Simple::Test::reset
      4.5.1 Command description
      4.5.2 Command public API
   4.6 ::Simple::Test::results
      4.6.1 Command description
         4.6.1.1 Overview
      4.6.2 Command public API
   4.7 ::Simple::Test::set-test-criteria testCriteria
      4.7.1 Command description
         4.7.1.1 Overview
      4.7.2 Command public API
      4.7.3 Command further information
         4.7.3.1 Todo
   4.8 ::Simple::Test::shutdown
      4.8.1 Command description
      4.8.2 Command public API
   4.9 ::Simple::Test::statistics
      4.9.1 Command description
      4.9.2 Command public API
   4.10 test-case tag title ?-regexp? ?-prerequisites script-list? ?-dependencies testtag-list? ?-setup script? ?-script script? ?-cleanup script? ?-output string? ?-error string? ?-return string?
      4.10.1 Command description
         4.10.1.1 Overview
         4.10.1.2 Examples
      4.10.2 Command public API
      4.10.3 Command further information
         4.10.3.1 Remarks

1. Package description

Synopsis: the Simple Development Library regression testing framework.

Keywords: regression, test and package.

1.1 Overview

This package provides a complete framework for automated regression testing.

Procedures are provided to initialize, reset and shutdown the test environment, set criteria of which cases to test, run the test cases as well as others to obtain the test results and statistics.

1.2 Usage

The ::Simple::Test::initialize procedure sets up a test environment where test cases can be run via the test-case procedure. By using ::Simple::Test::set-test-criteria, one can set a criteria to specify which test cases to test or ignore.

Upon testing a test case, its prerequisites are first assessed; if any prerequisite is not fulfilled, the test case is skipped. Next, the list of dependencies are checked. If any of the dependencies did not pass, the test case is skipped. Otherwise, the test case is run, and by comparing its output, errors and return values with the corresponding expected values, each test is flagged as passed or failed.

The detailed test results and the flags given to the corresponding call to the test-case procedures are available via the ::Simple::Test::results and ::Simple::Test::flags procedures, respectively. Finally, the overall statistics of all the test cases can be obtained via the ::Simple::Test::statistics procedure.

Use ::Simple::Test::reset to reset the test environment and ::Simple::Test::shutdown to clean up after testing.

1.3 Examples

1.4 History

Date Reason
19-feb-1999 Unreleased first version 0.1
23-apr-2000 First public release, version 0.2
10-sep-2001 Second public release, version 0.4
17-feb-2003 Third public release, version 0.5
25-sep-2003 Named test interpreter, version 0.5.1
22-jun-2005 The Simple Development Library version 1.0

1.5 Copyright

Copyright (C) 1999-2005, Juan C. Gil (jgil@gmv.es).

2. Package public API

Paradigm: procedural.

Requisites: SimpleType 1.0.

2.1 Types

2.1.1 testtag

Description: test case tag: public-api-1, ...

2.1.2 testcriteria

Description: criteria for test cases to be tested: :, 3, 3,7, :7, ..

2.2 Options

2.2.1 -store

Type: list.

Value: (empty string).

Description: flags to store for each test case tested, which can later be obtained via the ::Simple::Test::flags procedure.

2.3 Namespaces

  1. ::Simple::Test

  2. ::Simple::Test::Priv

2.4 Commands

2.4.1 ::Simple::Test::cget ?-store?

Synopsis: gets the package options.

Details: see section 4.1.

2.4.2 ::Simple::Test::configure ?-store list?

Synopsis: configures the package options.

Details: see section 4.2.

2.4.3 ::Simple::Test::flags

Synopsis: returns the test stored flags.

Details: see section 4.3.

2.4.4 ::Simple::Test::initialize

Synopsis: initializes the test environment.

Details: see section 4.4.

2.4.5 ::Simple::Test::reset

Synopsis: resets the test environment.

Details: see section 4.5.

2.4.6 ::Simple::Test::results

Synopsis: returns the test cases results.

Details: see section 4.6.

2.4.7 ::Simple::Test::set-test-criteria testCriteria

Synopsis: sets the criteria to specify which test cases to test.

Details: see section 4.7.

2.4.8 ::Simple::Test::shutdown

Synopsis: shutdowns the test environment.

Details: see section 4.8.

2.4.9 ::Simple::Test::statistics

Synopsis: returns test cases statistics.

Details: see section 4.9.

2.4.10 test-case tag title ?-regexp? ?-prerequisites script-list? ?-dependencies testtag-list? ?-setup script? ?-script script? ?-cleanup script? ?-output string? ?-error string? ?-return string?

Synopsis: runs a test case.

Details: see section 4.10.

2.5 Errors

2.5.1 ::Simple::Test::ENVIRONMENT-NOT-INITIALIZED

Message: test environment not initialized.

Explanation: the attempted operation requires an initialized test environment.

Corrective action: use the ::Simple::Test::initialize procedure to initialize the test environment.

2.5.2 ::Simple::Test::NO-SCRIPT-FLAG

Message: no -script for test "test case tag".

Explanation: test case test case tag lacks the compulsory -script flag.

2.5.3 ::Simple::Test::RETURN-AND-ERROR-FLAGS

Message: both -return and -error given for test case "test case tag".

Explanation: test case test case tag has both -return and -error flags, but these are mutually exclusive.

2.5.4 ::Simple::Test::BAD-SET-OF-RANGES

Message: bad set of ranges "ranges", range "range" is not well formed.

Explanation: the set of ranges ranges ranges has bad format; range is the bad range.

Corrective action: a set of ranges is one or more ranges separated by commas. A range is one unsigned integer or two unsigned integers separated by a colon where the first, the second or even both unsigned integers may not be present, meaning that the range is open by the left, by the right, or by both ends, respectively.

2.5.5 ::Simple::Test::BAD-FLAG-TO-STORE

Message: bad flag to store "flag": must be -cleanup, -dependencies, -error, -output, -prerequisites, -regexp, -return, -script or -setup.

Explanation: flag flag is not allowed.

Corrective action: supply a flag among those in the list.

3. Package further information

3.1 Details

3.2 Todo

4. Package command details

4.1 ::Simple::Test::cget ?-store?

4.1.1 Command description

Synopsis: gets the package options.

Access mode: public.

4.1.2 Command public API

Arguments:

Argument Type Default value/ choices Description
-store boolflag (n/a) Gets the list of options to store for each test case tested which can be later be obtained via the ::Simple::Test::flags procedure. The returned list of options options is ordered as in the input to the corresponding test-case procedure.

Returns: the requested option value or the whole list of options if none specified.

4.2 ::Simple::Test::configure ?-store list?

4.2.1 Command description

Synopsis: configures the package options.

Access mode: public.

4.2.2 Command public API

Arguments:

Argument Type Default value/ choices Description
?-store? list (empty string) Flags to store for each test case tested, which can be later be obtained via the ::Simple::Test::flags procedure. If the given argument is "all", then all options are stored.

Returns: the empty string.

4.3 ::Simple::Test::flags

4.3.1 Command description

Synopsis: returns the test stored flags.

Access mode: public.

4.3.1.1 Overview

This procedure returns a list containing the stored flags and their contents for a test case as given to the corresponding test-case procedure. Each element in the list is a list of two-element lists, being the first a flag and the second its contents; this format is suitable to be used with the array get command. As -regexp is a boolean flag, its contents is set to the empty string.

The stored flag are those of the -store package option. By default, no flags are stored. Nevertheless, if a test case fails the given items among those in the -store package option are stored along with the -regexp flag. If the test case throws an error when no error was expected, this procedure return an -error flag with "NONE" as contents.

4.3.2 Command public API

Arguments: none.

Returns: the test cases flags.

4.4 ::Simple::Test::initialize

4.4.1 Command description

Synopsis: initializes the test environment.

Access mode: public.

4.4.2 Command public API

Arguments: none.

Returns: the empty string.

Effects:

4.4.3 Command further information

4.4.3.1 Remarks

4.5 ::Simple::Test::reset

4.5.1 Command description

Synopsis: resets the test environment.

Access mode: public.

4.5.2 Command public API

Arguments: none.

Returns: the empty string.

4.6 ::Simple::Test::results

4.6.1 Command description

Synopsis: returns the test cases results.

Access mode: public.

4.6.1.1 Overview

This procedure returns a list containing for each test case tested the following elements:

0 number
1 tag
2 title
3 whether it was ignored
4 whether it was skipped
5 whether it was passed or failed
6 in case it failed, the diagnostics; this is a list of two-elements lists, being the first element a reason and the second extra information

Possible reasons and their corresponding extra information are the following:

Reason Extra information
Dependencies failed List of failed dependencies
Prerequisite failed Error information (::errorInfo contents)
Unfulfilled prerequisite Prerequisite script failed
Setup failed Error information (::errorInfo contents)
Cleanup failed Error information (::errorInfo contents)
Actual output Actual test case output
Actual error Actual test case error
Actual return Actual test case return
Error information Error information (::errorInfo contents)

The actual output, error or return appears when they did not match the expected output, error or return values, respectively. Notice that the actual output may appear together with the actual error or return, but not both. The error information appears when an error is thrown from the test case script.

4.6.2 Command public API

Arguments: none.

Returns: the test cases results.

4.7 ::Simple::Test::set-test-criteria testCriteria

4.7.1 Command description

Synopsis: sets the criteria to specify which test cases to test.

Access mode: public.

4.7.1.1 Overview

This procedure sets the expression that specifies which test cases to test from the given criteria. Test cases matching the criteria are tested while all others are ignored.

4.7.2 Command public API

Arguments:

Argument Type Default value/ choices Description
testCriteria testcriteria (n/a) Criteria of which test cases to test

Returns: the empty string.

4.7.3 Command further information

4.7.3.1 Todo

4.8 ::Simple::Test::shutdown

4.8.1 Command description

Synopsis: shutdowns the test environment.

Access mode: public.

4.8.2 Command public API

Arguments: none.

Returns: the empty string.

Effects:

4.9 ::Simple::Test::statistics

4.9.1 Command description

Synopsis: returns test cases statistics.

Access mode: public.

4.9.2 Command public API

Arguments: none.

Returns: a list with the following elements:

0 number of test cases executed
1 number of test cases passed
2 number of test cases failed
3 number of test cases skipped
4 number of test cases ignored

4.10 test-case tag title ?-regexp? ?-prerequisites script-list? ?-dependencies testtag-list? ?-setup script? ?-script script? ?-cleanup script? ?-output string? ?-error string? ?-return string?

(Exported from ::Simple::Test).

4.10.1 Command description

Synopsis: runs a test case.

Access mode: exported.

Keywords: test.

4.10.1.1 Overview

This is the actual test case handler. Works by running the test case in the test environment where the output of puts is available at the end. If that output matches the expected output and any error message and return values match the expected ones, the test case is considered passed, otherwise the test fails. The output of this procedure is stored and can be obtained via the ::Simple::Test::results procedure.

If the expected output, return value or error are empty, the test passes only if it does not produce any output, return value or error, respectively. If the expected return value or error is not given, then its actual value is not checked.

By specifying the -regexp flag, the expected output and return value or error are matched as regular expressions so that it is possible to validate non-constant values.

Before running the test case, each prerequisite in the list of prerequisites is evaluated. If any of them fails, the test is skipped. Next, the list of dependencies is checked. If any of the dependencies does not pass, the test is skipped.

Otherwise, the setup script is evaluated afterwards. If there is an error, the test is failed. Otherwise, the actual test is run followed by the cleanup script. An error in the cleanup script also results in the test case to be regarded as failed.

4.10.1.2 Examples

4.10.2 Command public API

Arguments:

Argument Type Default value/ choices Description
tag testtag (n/a) Test case tag
title string (n/a) Test case title
-regexp boolflag (n/a) Whether the expected output, return and error shall be matched as regular expressions
?-prerequisites? script-list (empty string) Prerequisites scripts list
?-dependencies? testtag-list (empty string) List of test cases tags this test depends on
?-setup? script (empty string) Setup script
?-script? script (empty string) Test case script
?-cleanup? script (empty string) Cleanup script
?-output? string (empty string) Test case expected output
?-error? string (empty string) Test case expected error
?-return? string (empty string) Test case expected return

Returns: whether the test passed or not.

Effects:

4.10.3 Command further information

4.10.3.1 Remarks