Next: (veritas veritas), Previous: (veritas snapshot), Up: API
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.
Index cases by key, giving an alist of key to case.
Handy for tables with named columns.
Like test-each, but case->suite returns a suite.
Use it when one case needs several tests rather than one.
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))))))