In-process capture of clojure.test execution.
Capture is represented by an explicit context that can be dynamically replaced or disabled. clojure.test/report hooks and routing writers consult the current dynamic context at event/write time, which lets nested scry runs install their own capture state and lets foreign runners run with scry capture disabled. The public result model remains built from per-var entries containing assertion events and stdout/stderr buffers.
In-process capture of clojure.test execution. Capture is represented by an explicit context that can be dynamically replaced or disabled. clojure.test/report hooks and routing writers consult the current dynamic context at event/write time, which lets nested scry runs install their own capture state and lets foreign runners run with scry capture disabled. The public result model remains built from per-var entries containing assertion events and stdout/stderr buffers.
The dynamically active capture context.
The private root sentinel means no dynamic capture boundary has been installed. nil is an explicit disabled context and must not fall back to an enclosing/supplied state.
The dynamically active capture context. The private root sentinel means no dynamic capture boundary has been installed. nil is an explicit disabled context and must not fall back to an enclosing/supplied state.
(assertion m contexts)Extract the inspectable subset of a clojure.test assertion report map.
contexts is the vector of active testing strings, outermost first. For
errors a rendered :stacktrace string is added.
Extract the inspectable subset of a clojure.test assertion report map. `contexts` is the vector of active `testing` strings, outermost first. For errors a rendered :stacktrace string is added.
(build-result state-or-context
{:keys [duration-ms scope result-format] :or {scope :suite}})Build the scoped result map from captured state/context.
Options may include :duration-ms, :scope, and :result-format.
Build the scoped result map from captured state/context. Options may include :duration-ms, :scope, and :result-format.
(canonical-results state-or-context)Return unprojected result entries for every executed test var in state/context.
Return unprojected result entries for every executed test var in state/context.
(context-disabled?)Return true when the current dynamic boundary explicitly disables capture.
Return true when the current dynamic boundary explicitly disables capture.
(current-var-result state-or-context)Return the canonical result entry for the current or just-completed var.
This remains useful for end-of-var progress callbacks while also supporting the newer callback timing after :each fixture teardown.
Return the canonical result entry for the current or just-completed var. This remains useful for end-of-var progress callbacks while also supporting the newer callback timing after :each fixture teardown.
Default scoped result-format configuration.
Default scoped result-format configuration.
(format-result result scope result-format)Format a canonical result map for scope using optional result-format overrides.
Format a canonical result map for `scope` using optional result-format overrides.
(new-context)(new-context {:keys [state intended-vars metadata]})Create a capture context.
Options: :state raw capture state atom; omitted creates a fresh state :intended-vars collection of Vars owned by this context. nil means accept all vars, preserving direct helper-test semantics. :metadata optional caller metadata retained for diagnostics.
Create a capture context.
Options:
:state raw capture state atom; omitted creates a fresh state
:intended-vars collection of Vars owned by this context. nil means
accept all vars, preserving direct helper-test semantics.
:metadata optional caller metadata retained for diagnostics.(new-state)Create a fresh capture state atom.
:current the owned Var currently reporting assertions :output-owner the Var currently receiving routed output :frames stack of owned/ignored clojure.test var frames :order Vars in encounter order :vars map of Var -> per-var capture entry :provisional non-public buffers/events for an output owner before clojure.test begins the var :counts running clojure.test counters for owned vars :orphan output buffers for writes outside any public test var
Create a fresh capture state atom.
:current the owned Var currently reporting assertions
:output-owner the Var currently receiving routed output
:frames stack of owned/ignored clojure.test var frames
:order Vars in encounter order
:vars map of Var -> per-var capture entry
:provisional non-public buffers/events for an output owner before
clojure.test begins the var
:counts running clojure.test counters for owned vars
:orphan output buffers for writes outside any public test var(orphan-output state-or-context)Return output captured outside any public test var as {:out s :err s}.
Return output captured outside any public test var as {:out s :err s}.
(report-fn)(report-fn state-or-context)Return a clojure.test/report replacement.
With no arguments, report events dispatch through the dynamically active context and are ignored when no context is installed or capture is disabled. With a state/context argument, direct tests keep legacy state-closing behavior, except an explicit disabled context still ignores events instead of falling back to the supplied state.
Return a clojure.test/report replacement. With no arguments, report events dispatch through the dynamically active context and are ignored when no context is installed or capture is disabled. With a state/context argument, direct tests keep legacy state-closing behavior, except an explicit disabled context still ignores events instead of falling back to the supplied state.
(routing-writer stream-key)(routing-writer state-or-context stream-key)Return a java.io.Writer that routes writes for stream-key (:out or :err).
Arity 1 is the runner-facing form and consults the dynamic capture context at write time, falling back to the writer active at construction when capture is disabled. Arity 2 preserves direct state/context-based tests when no dynamic context has been installed; an explicit disabled context still routes to the fallback writer instead of the supplied state.
Return a java.io.Writer that routes writes for `stream-key` (:out or :err). Arity 1 is the runner-facing form and consults the dynamic capture context at write time, falling back to the writer active at construction when capture is disabled. Arity 2 preserves direct state/context-based tests when no dynamic context has been installed; an explicit disabled context still routes to the fallback writer instead of the supplied state.
(summary-line result)A terse one-line human summary of a result's :summary.
A terse one-line human summary of a result's :summary.
(var-result state-or-context v)Return the canonical result entry for Var v from state/context.
Return the canonical result entry for Var `v` from state/context.
(with-context context & body)Evaluate body with context as the active scry capture context.
Evaluate body with `context` as the active scry capture context.
(with-output-owner state-or-context v f)Run f while routed output for the active/supplied context belongs to v.
This does not create clojure.test report frames, public result entries, or test counts. Fixture setup output/assertions are held provisionally until clojure.test actually begins the var; if an :each fixture short-circuits and never calls the test function, provisional output is kept non-public.
Run `f` while routed output for the active/supplied context belongs to `v`. This does not create clojure.test report frames, public result entries, or test counts. Fixture setup output/assertions are held provisionally until clojure.test actually begins the var; if an :each fixture short-circuits and never calls the test function, provisional output is kept non-public.
(without-context & body)Evaluate body with scry capture explicitly disabled.
Evaluate body with scry capture explicitly disabled.
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 |