[plt-scheme] Setup and teardown in SchemeUnit

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Dec 1 02:54:01 EST 2008

And it's a brand new day...

Abstract over a test-case with the setup you want:

(define-syntax my-test-case
  (syntax-rules ()
    [(my-test-case name expr ...)
     (test-case  name (before (my-before-expr) expr ...))]))

(my-test-case (+ 1 1))
(my-test-case (+ 2 2))
...

A class is the main unit of abstraction in Java/Python, with
overloading the main method of extension.  In Scheme its a functions
and function parameterisation respectively, so the mechanism of
setup/teardown changes to match the language (and I use a macro above
for reasons that aren't really important).

Adding setup/teardown arguments to test-begin/test-case is something
that might be worth doing.  In my experience I don't need this often
enough to justify it.

N.


Posted on the users mailing list.