[plt-scheme] Setup and teardown in SchemeUnit

From: Michał Kwiatkowski (constant.beta at gmail.com)
Date: Sun Nov 30 18:20:56 EST 2008

On Mon, Dec 1, 2008 at 12:04 AM, Dave Gurnell <d.j.gurnell at gmail.com> wrote:
> You could use a macro for abstraction like this (wrote this straight into
> the email - probably contains typos):
>
>  (define-syntax-rule (my-before expr ...)
>    (before
>      (begin (display "Before") (newline))
>      expr ...))
>
>  (test-case "blah"
>    (my-before
>      (check-equal? 0 0)
>      (check-equal? 1 1)
>      (check-equal? 2 2)))
>
> The macro can expand to a (test-case ...) form if you want to save extra
> typing.

That would still run the setup only once.

Cheers,
mk


Posted on the users mailing list.