Fiveam Test Framework – 1.2.3

Update: if anyone knows how to make Textile 2 not mess with my lisp code and get all confused, I’d be obliged.

I’ve been using the fiveam test framework for common lisp. It has the usual features you’d expect from an xUnit style test framework, but the programmer’s interface to it is far cry from

The is macro is cool. When the test fails, it can figure out whether to present the programmer with two non-matching values or just show that an expression was false.

Fixtures, instead of being classes, (an OO cluge in my opinion) are just “with” macros.


(eval-when (:compile-toplevel :load-toplevel :execute)
  (def-fixture temp-dir ()
    (let ((tmpname (make-pathname :directory '(:relative "tmp"))))
      (flet ((dumpfile (name contents)
               (let ((target (merge-pathnames tmpname name)))
                 (ensure-directories-exist target)
                 (with-open-file (s target
                                    :direction :output
                                    :if-does-not-exist :create)
                   (write-sequence contents s)))))
        (ensure-directories-exist tmpname)
        (&body)
        (kmrcl:delete-directory-and-files tmpname)))))

(test another-test ()
    (with-fixture temp-dir ()
        (... more "is" tests ...))))))))))

My lisp skills are a bit clumsy, but this framework leaves me with elegant tests. I like it.

Advertisement
Explore posts in the same categories: General

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.