Next: , Previous: , Up: API  


1.13 (veritas table)

Table-driven tests, in the spirit of pytest’s parametrize, JUnit’s parameterized tests and Go’s table tests. One test definition is expanded over a list of cases and each case is reported as its own test, so a failure points at the exact input.

1.13.1 Procedures

Procedure: cases->table cases key

Index cases by key, giving an alist of key to case.

Handy for tables with named columns.

Procedure: suite-each group-name cases case->suite KEY: #:shuffle? #:concurrent?

Like test-each, but case->suite returns a suite.

Use it when one case needs several tests rather than one.

Procedure: test-each group-name cases case->test KEY: #:shuffle? #:concurrent?

Expand cases into one test per case, under a suite named group-name.

case->test takes one case and returns a test:

(test-each "integer addition"
           '((0 0 0) (1 2 3) (10 20 30))
           (lambda (case)
             (let ((a (list-ref case 0))
                   (b (list-ref case 1))
                   (expected (list-ref case 2)))
               (test (format #f "~a + ~a = ~a" a b expected)
                 (assert-equal #:expect expected #:got (+ a b))))))