Skip to content
marick edited this page Feb 15, 2013 · 11 revisions

The features described here are available in Midje 1.5 and later.

In short

By way of background: when facts are loaded, they're converted into values (functions with a particular calling convention) that are stored in a compendium. By default, they're also checked as they're loaded. (Although that's a configuration setting.) The last fact checked is remembered specially.

The repl tools allow you to work with that compendium. They also support autotesting, which tracks changes to files and reloads (and rechecks) them as needed.

This page gives a brief summary of the various commands.

Autotesting (Details)

(autotest)
(autotest :dirs "test/midje/util" "src/midje/util")

(autotest :pause)
(autotest :resume)
(autotest :stop)

Loading facts into memory and working with them. (Details)

(Some of these commands work with fact metadata.)

  • load-facts: Load namespaces and check facts.
(load-facts)       ;; Initially, load everything. Subsequently, load the last "working set"
(load-facts :all)  ;; Load everything.
(load-facts 'proj.namespace 'proj.other.namespace)
(load-facts 'proj.subdir.*)  ;; Load a namespace tree.

The :all argument replaces everything in the compendium. When explicit namespaces are given, they will replace themselves (if they were already present). However, other namespaces stay in the compendium. That is, suppose that you make the following two commands:

(load-facts 'proj.util.*)
(load-facts 'proj.chairs.*)

At the end of the second command, both sets of namespaces are in the compendium.

Examples of other features:

(load-facts 'namespace :print-facts)  ;; Adjust print verbosity while loading

;; Load facts works with metadata
(load-facts :integration)  ;; Load only integration tests
(load-facts (complement :integration) ;; Load non-namespace tests
(load-facts "cute")     ;; Load only facts with "cute" in their names (doc strings)
(load-facts #"cute[0-6]" ;; Load only facts whose names match the regular expression
(load-facts some-arbitrary-function-over-a-metadata-map)
  • check-facts: Check some or all of the loaded facts again (without reloading them)
(check-facts)                       ;; Recheck same facts over again.
(check-facts *ns* 'proj.t-cursor)   ;; Check a subset of the compendium by namespace.
(check-facts :all)                  ;; Check everything (if a previous command narrows the "working set")

check-facts takes the same filter and verbosity arguments as load-facts.

  • forget-facts: Forget some or all of the loaded facts
(forget-facts :all)                 ;; Forget everything
(forget-facts *ns* 'some.namespace) ;; Forget by namespace
(forget-facts)                      ;; Forget the current "working set".

forget-facts takes the same filter arguments as load-facts.

  • fetch-facts: Return a sequence of some or all of the loaded facts.
(fetch-facts :all)                  ;; Return all the facts in the compendium
(fetch-facts)                       ;; Fetch the current working set.
(fetch-facts *ns* 'some-namespace)  ;; Fetch by namespace

fetch-facts takes the same filter arguments as load-facts.

  • check-one-fact: Check a fact returned from fetch-facts.
(map check-on-fact (fetch-facts))

The most recently checked fact

  • recheck-fact: Check the last fact checked again.
  • last-fact-checked: Provide previous fact as a value.
  • source-of-last-fact-checked: Show source of previous fact.
user=> (fact (+ 1 1) => 3)

FAIL at (NO_SOURCE_FILE:1)
    Expected: 3
      Actual: 2
false
user=> (recheck-fact)

FAIL at (NO_SOURCE_FILE:1)
    Expected: 3
      Actual: 2
FAILURE: 1 claim was not confirmed. 
false
user=> (source-of-last-fact-checked)
(fact (+ 1 1) => 3)
user=> (check-one-fact (last-fact-checked))

FAIL at (NO_SOURCE_FILE:1)
    Expected: 3
      Actual: 2
false
Clone this wiki locally