;;;; ** Creating Suits
+ (defvar *suites* (make-hash-table))
+
-(defmacro def-suite (name &key description in)
+(defmacro def-suite (name &key description (in nil in-p) (fixture nil fixture-p))
"Define a new test-suite named NAME.
IN (a symbol), if provided, causes this suite te be nested in the
suite named by IN. NB: This macro is built on top of make-suite,
as such it, like make-suite, will overrwrite any existing suite
-named NAME."
+named NAME.
+
+DESCRIPTION is just a string.
+
+FIXTURE is the fixture argument (exactly like the :fixture argument to
+def-test) to pass to tests in this suite."
`(eval-when (:compile-toplevel :load-toplevel :execute)
- (make-suite ',name
- ,@(when description `(:description ,description))
- ,@(when in-p `(:in ',in))
- ,@(when fixture-p `(:fixture ',fixture)))
+ (setf (gethash ',name *suites*)
+ (make-suite ',name
+ ,@(when description `(:description ,description))
- ,@(when in `(:in ',in))))
++ ,@(when in-p `(:in ',in))
++ ,@(when fixture-p `(:fixture ',fixture))))
',name))
(defmacro def-suite* (name &rest def-suite-args)
(is (= 1 a))
(is (= 1 b))))
+ (def-test introspection ()
+ (is (= (length (list-all-suites))
- (hash-table-count *suites*))))
++ (hash-table-count *suites*))))
++
+(defvar *special-variable* nil)
+
+(def-fixture fixture-for-suite (value)
+ (progn
+ (setf *special-variable* value)
+ (&body)))
+
+(def-suite suite-with-fixture :fixture (fixture-for-suite 42) :in :it.bese.fiveam)
+
+(def-test test-with-suite-fixture (:suite suite-with-fixture)
+ (is (= 42 *special-variable*)))