-
Notifications
You must be signed in to change notification settings - Fork 129
Configuration files
This feature is available in Midje 1.5+.
On startup, Midje loads ${HOME}/.midje.clj
and ./.midje.clj
(in that order). You can change configuration files with lein-midje:
% lein midje :config config-file-1 config-file-2
The two given configuration files are used instead of the defaults. They're loaded in left-to-right order. Because :config
makes Midje forget the default files, you tell it to load no configuration files at all like this:
% lein midje :config
A configuration file is loaded within the midje.config
namespace. Within it, use change-defaults
to override Midje's defaults. Here, for example, is how you'd change midje's verbosity:
(change-defaults :print-level :print-namespaces)
If you want Midje to behave differently when run in the repl or via lein midje
, use running-in-repl?
(when (not (running-in-repl?))
(change-defaults :print-level :print-namespaces))
You can temporarily change the configuration like this:
(midje.config/with-augmented-config {:print-level :print-no-summary}
<forms>...)
-
:print-level <keyword>
Change the verbosity of Midje output. The default argument is
:print-normally
. See print levels for a list. -
:emitter <namespace name or string>
The "emitter" formats Midje output. The default emitter is
'midje.emission.plugins.default
. That's currently the only one. You can add your own, though. If that code is in your project classpath, you can use a namespace name (symbol) to identify it. You can also use a string to refer to a Clojure file that will be loaded withload-file
. Pqthnames can be absolute or relative to the project root. -
:check-after-creation <true or false>
By default, Midje facts are checked immediately as they're loaded. When set to
false
, you need to use a repl tool likecheck-facts
to check them. Note that autotest obeys this option. -
:visible-deprecation <true or false>
By default, Midje warns you (once) when you use a deprecated feature. This option can turn off those warnings.
-
:visible-future <true or false>
By default, Midje produces output for future facts (TODOs). This option can turn off that output.
-
:partial-prerequisites <true or false>
This option controls what happens when a prerequisite is called with unexpected arguments. Normally, it produces a failure. When this option is set to
true
, though, prerequisites become partial, which means that a call with unexpected arguments "falls through" to the true function (if it exists). That's useful for testing recursive functions. Remember that you can scope the behavior of prerequisites withwith-augmented-config
.