Liking cljdoc? Tell your friends :D

lazytest.hooks

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.
raw docstring

all-hook-keysclj

source

defhookcljmacro

(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):

  • 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:

(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)
  ...)
```
sourceraw docstring

hook-dispatchclj

(hook-dispatch _config _m hook-type)
source

profilingcljmultimethod

(profiling config m _hook-type)

Print the slowest namespaces and test vars by duration.

Print the slowest namespaces and test vars by duration.
sourceraw docstring

randomizecljmultimethod

(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.
sourceraw docstring

run-hooksclj

(run-hooks config m hook-type)
source

shuffle-with-seedclj

(shuffle-with-seed coll rng)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close