Skip to content
marick edited this page May 5, 2012 · 13 revisions

The hard-to-quantify

  • Compatible with Clojure 1.4. Still compatible with Clojure 1.2.0, 1.2.1, and 1.3.0.
  • Better reporting of test failures.
  • Better error reporting for many common test-writing mistakes.
  • Everything has doc strings.

A breaking change (obscure)

  • When a function-under-test makes a call to a prerequisite function and the given arguments don't match, Midje once again reports an error even if there's an implementation of the prerequisite function that it could call. The partial prerequisites behavior can still be enabled.

    Sorry, semver fans.

Facts

  • Facts now report their doc strings. Nested facts report nested descriptions.
          (facts "about arithmetic"
            (fact "addition"
              (+ 0 1) => 0))
            ;; FAIL "about arithmetic - addition" at (core.clj:18)
  • Tabular facts no longer require variable names to begin with "?".

Checkers

       (fact
         (/ 1 0) => (throws Exception #"Divide.+zero"))
  • every-checker and some-checker can be used to combine other checkers while still getting helpful failure messages.
        (fact 19 => (every-checker odd? (roughly 23)))
        ;; FAIL at (core.clj:15)
        ;; Actual result did not agree with the checking function.
        ;;         Actual result: 19
        ;;     Checking function: (every-checker odd? (roughly 23))
        ;;     During checking, these intermediate values were seen:
        ;;        (roughly 23) => false
  • Checker synonyms: FALSEY, TRUTHY, and irrelevant (for anything).
  • Chatty checkers can destructure their single argument.

Prerequisites

  • The =throws=> arrow can be used to throw exceptions.

  • You can use vars as well as symbols in prerequisites. This supports the Clojure idiom of using vars to reach functions declared private:

        (fact
          (counter 4) => 8
          (provided
            (#'scratch.core2/super-secret-function 4) => 4))

Other

  • expose-testables is another way to test private functions.
  • There are hooks for tool writers. Contact the authors for details.
Clone this wiki locally