Midje <https://github.com/marick/Midje> provides a migration path from
clojure.test to a more flexible, readable, abstract, and gracious style of
testing.
The 0.9 release mainly provides useful checkers for "collection-like things"
(collections and strings). Checkers are single-argument functions that produce
truth values:
(facts "about prime numbers"
(first (primes)) => even?
(second (primes)) => odd?)
Here are examples of the new checkers:
user> (fact "the quick brown fox" => (has-suffix "fox"))
true
;; I've tried to make diagnostics useful:
user> (fact "where is the animal?" => (contains "hen"))
FAIL at (NO_SOURCE_FILE:1)
Actual result did not agree with the checking function.
Actual result: "where is the animal?"
Checking function: (contains "hen")
The checker said this about the reason:
Best match found: [\h \e]
false
;; You can tell the checkers to ignore order or gaps:
user> (fact "where is the animal?" => (contains "hen" :gaps-ok))
true
user> (fact "where is the animal?" => (contains "lama" :in-any-order :gaps-ok))
true
;; "Lama" is too a valid alternate spelling of "llama".
;; The same checkers work on collections:
user> (fact [4 'h "regex" 2] => (contains [2 #"re" 4] :in-any-order :gaps-ok))
true
;; You can use checkers within checkers:
user> (fact {:a 1 :b 3 :c 5} => (just {:a odd? :b odd? :c odd?}))
true
... and so on. You can find a complete description here:
https://github.com/marick/Midje/wiki/Checkers-for-collections-and-strings
-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Author of /Ring/ (forthcoming; sample: http://bit.ly/hfdf9T)
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en