A hook is a function that implements one or more of the hook methods.
Hooks allow for modifying the state of a run while it is being executed.
A hook is a function that implements one or more of the hook methods. Hooks allow for modifying the state of a run while it is being executed.
(defhook hook-name & hook-methods)(defhook hook-name docstring & hook-methods)defhook generates a conforming multimethod with correct dispatch and :default behavior. Provided methods (except cli-opts) must accept a config map and a target object, and should return nil or the (potentially updated) target.
Allowed hook methods (with input notes):
config map)Example usage with optional docstring:
(defhook yell
"Prints a message at the start and end of the whole run."
(pre-test-run
[config m]
(println "STARTING")
m)
(post-test-run
[config m]
(println "ENDING")
m)
...)
`defhook` generates a conforming multimethod with correct dispatch and `:default` behavior. Provided methods (except `cli-opts`) must accept a config map and a target object, and should return `nil` or the (potentially updated) target.
Allowed hook methods (with input notes):
* cli-opts (input is a vector of cli options)
* config (input is the same `config` map)
* pre-test-run
* post-test-run
* pre-test-suite
* post-test-suite
* pre-test-case
* post-test-case
Example usage with optional docstring:
```clojure
(defhook yell
"Prints a message at the start and end of the whole run."
(pre-test-run
[config m]
(println "STARTING")
m)
(post-test-run
[config m]
(println "ENDING")
m)
...)
```(profiling config m _hook-type)Print the slowest namespaces and test vars by duration.
Print the slowest namespaces and test vars by duration.
(randomize config m _hook-type)Randomize the order of namespaces and suites in namespaces during a test run.
Randomize the order of namespaces and suites in namespaces during a test run.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |