Lightweight testing framework
Damien Diederen <dd@crosstwine.com>
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.
(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.
(defmethod VedaTestingError ((context VedaTestingContext) @rest args) ...)
Error is equivalent to (Log) followed by (Fail).
(defmethod VedaTestingErrorf ((context VedaTestingContext) format @rest args) ...)
Errorf is equivalent to (Logf) followed by (Fail).
(defmethod VedaTestingFail ((context VedaTestingContext)) ...)
Fail marks the function as having failed but continues execution.
(defmethod VedaTestingFailNow ((context VedaTestingContext)) ...)
FailNow marks the function as having failed and stops its execution. Execution will continue at the next test or benchmark.
(defmethod VedaTestingFatal ((context VedaTestingContext) @rest args) ...)
Fatal is equivalent to (Log) followed by (FailNow).
(defmethod VedaTestingFatalf ((context VedaTestingContext) format @rest args) ...)
Fatalf is equivalent to (Logf) followed by (FailNow).
(defmethod VedaTestingLog ((context VedaTestingContext) @rest args) ...)
Log formats its arguments using default formatting, and records the text in the error log.
(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.
(defun RunTests (tests @key options) ...)
RunTests runs the test functions in tests, a list of funcallable symbols, and generates reports according to the provided options.
(defun RunTestsFromFiles (files @key options) ...)
RunTestsFromFiles loads files in-order while monitoring the set of methods having the form
(defmethod Test_Xxx ((context VedaTestingContext)) ...)
then executes the newly-defined/redefined ones.
(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.