Skip to content

Using midje without Leiningen

Daniel Compton edited this page Mar 23, 2022 · 3 revisions

By default, Midje assumes you're using Leiningen, either directly via lein-midje or indirectly via the repl tools. (The repl tools look inside your project.clj file to find the :test-paths and :source-paths.)

If you're not using Leiningen, you have to do two things:

  1. Give Midje the classpath-relative locations of all the files that might contain facts. By default, this is ["test"].

  2. Arrange for the classpath to contain one or more roots that have the facts below them. (Note that Midje allows facts to appear next to source code, so one of the roots may be the root of the source tree.)

In the absence of a project.clj file, the simplest way to satisfy (1) is to put test and source paths in your configuration files. For example, the following configuration file entry replicates the default for project.clj:

(midje.util.ecosystem/set-leiningen-paths! {:test-paths ["test"], :source-paths ["src"]})

Classpath-setting is more tool-dependent. I hope that people who use common tools (like Immutant) will add notes to this page.

Clojure CLI

Midje can be run via Clojure CLI tools (aka tools.deps) with a one liner:

clj -e "(require 'midje.repl) (-> (midje.repl/load-facts) :failures (min 255) (System/exit))"
Clone this wiki locally