For Development HEAD DRAFTSearch (procedure/syntax/module):

Next: , Previous: , Up: Library modules - SRFIs   [Contents][Index]

11.15 srfi.64 - A Scheme API for test suites

Module: srfi.64

This module defines API to write a portable test suite. In Gauche, it is adapted to work with gauche.test native test framework (see gauche.test - Unit Testing).

If SRFI-64 tests are run during gauche.test the tests becomes a part of the whole gauche.test suite.

The recommended way is to write a test suite in pure srfi-64, then include it from the gauche test script:

(use gauche.test)
(test-start "the tests")
;; portable test
(include "test-suite-in-srfi-64")

;; gauche-specific test, if needed
...

(test-end)

If test-suite-in-srfi-64.scm is run by itself, it uses SRFI-64’s default reporting system. If it is run within gauche.test script, the results are reported via gauche.test, consolidated with other Gauche test results.


11.15.1 Test runner

In SRFI-64, tests are run with an active test runner which collects test results and emits reports. It allows users to provide custom runners to handle tailored reports suitable to the specific tests.

Test runner object

Record: test-runner

[SRFI-64]{srfi.64}

Function: test-runner? obj

[SRFI-64]{srfi.64}

Parameter: test-runner-current

[SRFI-64]{srfi.64}

Function: test-runner-get

[SRFI-64]{srfi.64}

Function: test-runner-simple

[SRFI-64]{srfi.64}

Function: test-runner-null

[SRFI-64]{srfi.64}

Function: test-runner-factory :optional factory

[SRFI-64]{srfi.64}

Running tests with a specified runner

Function: test-apply [runner] specifier … procedure

[SRFI-64]{srfi.64}

Macro: test-with-runner runner decl-or-expr …

[SRFI-64]{srfi.64}

Latest result properties

A runner holds a single alist to keep the latest result properties. Except the result-kind property, which is set by every basic test procedures, the usage of properties are up to the test runner and/or test writer.

Function: test-result-clear runner

[SRFI-64]{srfi.64}

Function: test-result-ref runner pname :optional default

[SRFI-64]{srfi.64}

Function: test-result-set! runnre pname value

[SRFI-64]{srfi.64}

Function: test-result-remove runner pname

[SRFI-64]{srfi.64}

Function: test-result-alist runner

[SRFI-64]{srfi.64}

Function: test-result-kind :optional runner

[SRFI-64]{srfi.64}

Function: test-passed? :optional runner

[SRFI-64]{srfi.64}

Keeping track of test status

Function: test-runner-pass-count runner
Function: test-runner-fail-count runner
Function: test-runner-xpass-count runner
Function: test-runner-xfail-count runner
Function: test-runner-skip-count runner

[SRFI-64]{srfi.64}

Function: test-runner-test-name runner

[SRFI-64]{srfi.64}

Function: test-runner-group-path runner

[SRFI-64]{srfi.64}

Function: test-runner-group-stack runner

[SRFI-64]{srfi.64}

Function: test-runner-aux-value runner
Function: test-runner-aux-value! runner value

[SRFI-64]{srfi.64}

Function: test-runner-reset runner

[SRFI-64]{srfi.64}

Callbacks

Function: test-runner-on-test-begin runner
Function: test-runner-on-test-begin! runner proc

[SRFI-64]{srfi.64}

Function: test-runner-on-test-end runner
Function: test-runner-on-test-end! runner proc

[SRFI-64]{srfi.64}

Function: test-runner-on-group-begin runner
Function: test-runner-on-group-begin! runner proc

[SRFI-64]{srfi.64}

Function: test-runner-on-group-end runner
Function: test-runner-on-group-end! runner proc

[SRFI-64]{srfi.64}

Function: test-runner-on-bad-count runner
Function: test-runner-on-bad-count! runner proc

[SRFI-64]{srfi.64}

Function: test-runner-on-bad-end-name runner
Function: test-runner-on-bad-end-name! runner proc

[SRFI-64]{srfi.64}

Function: test-runner-on-final runner
Function: test-runner-on-final! runner proc

[SRFI-64]{srfi.64}

Function: test-on-test-begin-simple runner
Function: test-on-test-end-simple runner
Function: test-on-group-begin-simple runner
Function: test-on-group-end-simple runner
Function: test-on-bad-count-simple runner actual-count expected-count
Function: test-on-bad-end-name-simple runner begin-name end-name

[SRFI-64]{srfi.64}


11.15.2 Test API

Test grouping

SRFI-64 tests can be grouped, and groups can be nested.

Function: test-begin suite-name :optional count

[SRFI-64]{srfi.64}

Function: test-end :optional suite-name

[SRFI-64]{srfi.64}

Function: test-group suite-name body …

[SRFI-64]{srfi.64}

Function: test-group-with-cleanup suite-name body … cleanup

[SRFI-64]{srfi.64}

Individual tests

Macro: test-assert [test-name] expr

[SRFI-64]{srfi.64}

Macro: test-eqv [test-name] expected test-expr
Macro: test-eq [test-name] expected test-expr
Macro: test-equal [test-name] expected test-expr

[SRFI-64]{srfi.64}

Macro: test-approximate [test-name] extected test-expr margin

[SRFI-64]{srfi.64}

Macro: test-error [[test-name] error-type] test-expr

[SRFI-64]{srfi.64}

Function: test-read-eval-string string

[SRFI-64]{srfi.64}


Next: , Previous: , Up: Library modules - SRFIs   [Contents][Index]


For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT