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 JUnit.
Where JUnit uses reflection and inheritance for test definition, Fiveam presents a more lispish macro interface.

(def-suite lpm-suite)
(in-suite lpm-suite)

(test my-test ()
    (is t)
    (is (equal "a" "a"))
)

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.

Advertisements
Explore posts in the same categories: General

4 Comments on “Fiveam Test Framework – 1.2.3”

  1. Eliam Arlet Says:

    HI! I’m using FiveAM but I have a problem.
    I need to make a unit test for UCW actions but for obvious reasons I get: #
    how I can get the input and output values???


  2. If you’re not using FiveAM anymore, what are you using now?


Leave a Reply

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

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 )

Google+ photo

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

Connecting to %s


%d bloggers like this: