Hi folks,
I finally came up with fixtures for clojure.contrib.test-is.  Now you
can do before/after setup for each test case.  Here's the
documentation, let me know what you think.
-Stuart Sierra

  ;; FIXTURES (new)
  ;;
  ;; Fixtures allow you to run code before and after tests, to set up
  ;; the context in which tests should be run.
  ;;
  ;; A fixture is just a function that calls another function passed
as
  ;; an argument.  It looks like this:
  (defn my-fixture [f]
    ;; Perform setup, establish bindings, whatever.
    (f) ;; Then call the function we were passed.
    ;; Tear-down / clean-up code here.
    )

  ;; Fixtures are attached to namespaces in one of two ways.  "each"
  ;; fixtures are run repeatedly, once for each test function created
  ;; with "deftest" or "with-test".  "each" fixtures are useful for
  ;; establishing a consistent before/after state for each test, like
  ;; clearing out database tables.
  ;;
  ;; "each" fixtures can be attached to the current namespace like
this:
  (use-fixtures :each fixture1 fixture2 ...)
  ;; The fixture1, fixture2 are just functions like the example above.
  ;; They can also be anonymous functions, like this:
  (use-fixtures :each (fn [f] setup... (f) cleanup...))
  ;;
  ;; The other kind of fixture, a "once" fixture, is only run once,
  ;; around ALL the tests in the namespace.  "once" fixtures are
useful
  ;; for tasks that only need to be performed once, like establishing
  ;; database connections, or for time-consuming tasks.
  ;;
  ;; Attach "once" fixtures to the current namespace like this:
  (use-fixtures :once fixture1 fixture2 ...)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to