Package testing

Lightweight testing framework

Author

Damien Diederen  <dd@crosstwine.com>

Overview

Package testing (global prefix VedaTesting) provides support for automated testing of SKILL(++) packages. It is a port of the Go testing framework (http://golang.org/src/pkg/testing/testing.go) as provided by go1.0.2.

It is intended to select and automate the execution of any method of the form

(defmethod Test_Xxx ((context VedaTestingContext)) ...)

where Xxx can be any alphanumeric string (but the first letter must not be in [a-z]) and serves to identify the test routine. These Test_Xxx routines should be declared within the package they are testing, in files ending in -test.il or -test.ils.

This package does not yet implement the BenchmarkXxx or Example{F,T,T_M} features of the Go testing package.

Index

Class VedaTestingContext
    Slot ?name, GetName
    Slot GetFailed, SetFailed
    Slot GetDuration
Class VedaTestingOptions
    Slot ?verbose, GetVerboseLevel, SetVerboseLevel
    Slot ?reportFormat, GetReportFormat, SetReportFormat
    Slot ?reportFilename, GetReportFilename, SetReportFilename
Method VedaTestingError ((context VedaTestingContext) @rest args)
Method VedaTestingErrorf ((context VedaTestingContext) format @rest args)
Method VedaTestingFail ((context VedaTestingContext))
Method VedaTestingFailNow ((context VedaTestingContext))
Method VedaTestingFatal ((context VedaTestingContext) @rest args)
Method VedaTestingFatalf ((context VedaTestingContext) format @rest args)
Method VedaTestingLog ((context VedaTestingContext) @rest args)
Method VedaTestingLogf ((context VedaTestingContext) format @rest args)
Function VedaTestingRunTests (tests @key options)
Function VedaTestingRunTestsFromFiles (files @key options)
Function VedaTestingRunTestsOnPackage (pkg @key options)

Package files

testing.ils

Details

Class VedaTestingContext

(defclass VedaTestingContext () ...)

Context instances are passed to Test methods to manage test state and support test logs. Logs are accumulated during execution and dumped to a file or standard output depending on configuration options.

Slot ?name, GetName

@initarg ?name
@reader  GetName

Name of the test being executed.

Slot GetFailed, SetFailed

@reader  GetFailed
@writer  SetFailed

A boolean indicating whether the test has failed or not. Defaults to nil.

Slot GetDuration

@reader  GetDuration

The duration of the text execution, in seconds, or nil if the test hasn't been run or timing could not be measured.

Class VedaTestingOptions

(defclass VedaTestingOptions () ...)

Class VedaTestingOptions holds the options that are used for running tests.

Slot ?verbose, GetVerboseLevel, SetVerboseLevel

@initarg ?verbose
@reader  GetVerboseLevel
@writer  SetVerboseLevel

Verbosity level. Chatty above 4; defaults to 0.

Slot ?reportFormat, GetReportFormat, SetReportFormat

@initarg ?reportFormat
@reader  GetReportFormat
@writer  SetReportFormat

Report format, one of the following symbols: (text xml void). Defaults to text.

Slot ?reportFilename, GetReportFilename, SetReportFilename

@initarg ?reportFilename
@reader  GetReportFilename
@writer  SetReportFilename

Filename used by XML report writer. Defaults to nil, which maps to "./result.xml".

Method VedaTestingError

(defmethod VedaTestingError ((context VedaTestingContext) @rest args) ...)

Error is equivalent to (Log) followed by (Fail).

Method VedaTestingErrorf

(defmethod VedaTestingErrorf ((context VedaTestingContext) format @rest args) ...)

Errorf is equivalent to (Logf) followed by (Fail).

Method VedaTestingFail

(defmethod VedaTestingFail ((context VedaTestingContext)) ...)

Fail marks the function as having failed but continues execution.

Method VedaTestingFailNow

(defmethod VedaTestingFailNow ((context VedaTestingContext)) ...)

FailNow marks the function as having failed and stops its execution. Execution will continue at the next test or benchmark.

Method VedaTestingFatal

(defmethod VedaTestingFatal ((context VedaTestingContext) @rest args) ...)

Fatal is equivalent to (Log) followed by (FailNow).

Method VedaTestingFatalf

(defmethod VedaTestingFatalf ((context VedaTestingContext) format @rest args) ...)

Fatalf is equivalent to (Logf) followed by (FailNow).

Method VedaTestingLog

(defmethod VedaTestingLog ((context VedaTestingContext) @rest args) ...)

Log formats its arguments using default formatting, and records the text in the error log.

Method VedaTestingLogf

(defmethod VedaTestingLogf ((context VedaTestingContext) format @rest args) ...)

Logf formats its arguments according to the format, analogous to printf, and records the text in the error log.

Function VedaTestingRunTests (exported)

(defun RunTests (tests @key options) ...)

RunTests runs the test functions in tests, a list of funcallable symbols. Returns t if none of the tests failed, nil otherwise.

Test execution and report generation is controlled via ?options; if nil, a default-initialized instance of VedaTestingOptions is used.

Parameters:
tests – list
options – (or VedaTestingOptions list)
Returns:
(or symbol list)

Function VedaTestingRunTestsFromFiles (exported)

(defun RunTestsFromFiles (files @key options) ...)

RunTestsFromFiles loads files, a list of filenames, while monitoring the set of methods having the following form:

(defmethod Test_Xxx ((context VedaTestingContext)) ...)

It then executes the newly-defined/redefined ones.

Cf. RunTests for more information about ?options.

Parameters:
files – list
options – (or VedaTestingOptions list)
Returns:
(or symbol list)

Function VedaTestingRunTestsOnPackage (exported)

(defun RunTestsOnPackage (pkg @key options) ...)

RunTestsOnPackage finds the set of source and test files associated with package pkg, reloads all the source files, then loads and runs all the tests contained in the test files.

Cf. RunTests for more information about ?options.

Parameters:
pkg – string
options – (or VedaTestingOptions list)
Returns:
(or symbol list)