Public entry point for scry, an in-process test runner for AI agents.
run executes clojure.test tests in-process and returns an inspectable
result map; the most recent result is retained for interactive inspection
through last-result. The optional Kaocha adapter lives in scry.kaocha
and is available when the adapter artifact or equivalent optional Kaocha
classpath is present.
Public entry point for scry, an in-process test runner for AI agents. `run` executes clojure.test tests in-process and returns an inspectable result map; the most recent result is retained for interactive inspection through `last-result`. The optional Kaocha adapter lives in `scry.kaocha` and is available when the adapter artifact or equivalent optional Kaocha classpath is present.
(failed-test var-sym)(failed-test result var-sym)Return the failure/error entry for fully-qualified test var symbol var-sym.
Return the failure/error entry for fully-qualified test var symbol `var-sym`.
(failures)(failures result)Return failure/error entries of result (defaults to the last run).
Prefers the compatibility :failures collection when present and otherwise filters canonical :results. Returns an empty vector when the selected result format omits both collections.
Return failure/error entries of `result` (defaults to the last run). Prefers the compatibility :failures collection when present and otherwise filters canonical :results. Returns an empty vector when the selected result format omits both collections.
(last-result)Return the most recent run result, or nil if nothing has run.
Return the most recent run result, or nil if nothing has run.
(output var-sym)(output result var-sym)Return {:out s :err s} captured for failed test var var-sym, when present.
Return {:out s :err s} captured for failed test var `var-sym`, when present.
(report-string)(report-string result)Render a human/agent-readable report of result (defaults to last run).
Render a human/agent-readable report of `result` (defaults to last run).
(run)(run opts)Run clojure.test tests in-process and return the inspectable result map.
Options: :dirs test directories to scan (default ["test"]) :namespaces explicit collection of namespace symbols to run :ns-pattern regex matching namespace names to run :vars explicit collection of test var refs to run :result-format per-scope formatting overrides (see below)
The result is also available through last-result.
Result shape
By default a result has this top-level shape:
{:summary {:test 0 :pass 0 :fail 0 :error 0 :duration-ms 0.0
:var-count 0 :fail-var-count 0}
:pass? true
:results []
:failures []}
:results is the canonical formatted collection. :failures is a
compatibility collection holding the failing/erroring subset when the
selected format includes it.
Scoped detail
Default entry detail depends on how the run was invoked:
(run), multiple namespaces, or multiple vars):
compact entries for failing/erroring vars only, each with
:assertion-summary; no per-assertion details or output.{:namespaces ['my.ns-test]}): an entry for every
executed var, including passing vars, with all assertion details; no
stdout/stderr keys.{:vars [#'my.ns-test/a-test]}): one entry with all
assertion details and captured :out/:err.A detailed entry looks like:
{:var 'my.ns-test/a-test
:ns 'my.ns-test
:status :pass ;; :pass, :fail, :error, or rarely :unknown
:assertions [{:type :pass :message nil
:expected '(= 2 (+ 1 1)) :actual '(= 2 (+ 1 1))
:file "ns_test.clj" :line 42
:contexts ["outer" "inner"]}]
:out "captured stdout"
:err "captured stderr"}
Error assertions also include :stacktrace. A compact suite-scope entry
looks like:
{:var 'my.ns-test/a-test :ns 'my.ns-test :status :fail
:assertion-summary {:pass 0 :fail 1 :error 0}}
Custom result formatting
:result-format overrides returned keys and inclusions per scope. Scopes are
:suite, :namespace, and :var; each supports:
:top-level-keys top-level keys to return
:entry-keys keys to project for each result entry
:assertions? authoritative assertion gate; true adds :assertions,
false removes it
:output? authoritative output gate; true adds :out/:err,
false removes them
For example:
(run {:namespaces ['my.ns-test]
:result-format {:namespace {:top-level-keys [:summary :pass? :results]
:entry-keys [:var :status]
:assertions? true
:output? false}}})
If custom :top-level-keys omits both :results and :failures, helpers
such as failures return empty/nil values because there is no collection to
inspect.
Run clojure.test tests in-process and return the inspectable result map.
Options:
:dirs test directories to scan (default ["test"])
:namespaces explicit collection of namespace symbols to run
:ns-pattern regex matching namespace names to run
:vars explicit collection of test var refs to run
:result-format per-scope formatting overrides (see below)
The result is also available through `last-result`.
Result shape
By default a result has this top-level shape:
{:summary {:test 0 :pass 0 :fail 0 :error 0 :duration-ms 0.0
:var-count 0 :fail-var-count 0}
:pass? true
:results []
:failures []}
`:results` is the canonical formatted collection. `:failures` is a
compatibility collection holding the failing/erroring subset when the
selected format includes it.
Scoped detail
Default entry detail depends on how the run was invoked:
- Suite or multi scope (`(run)`, multiple namespaces, or multiple vars):
compact entries for failing/erroring vars only, each with
`:assertion-summary`; no per-assertion details or output.
- Single namespace scope (`{:namespaces ['my.ns-test]}`): an entry for every
executed var, including passing vars, with all assertion details; no
stdout/stderr keys.
- Single var scope (`{:vars [#'my.ns-test/a-test]}`): one entry with all
assertion details and captured `:out`/`:err`.
A detailed entry looks like:
{:var 'my.ns-test/a-test
:ns 'my.ns-test
:status :pass ;; :pass, :fail, :error, or rarely :unknown
:assertions [{:type :pass :message nil
:expected '(= 2 (+ 1 1)) :actual '(= 2 (+ 1 1))
:file "ns_test.clj" :line 42
:contexts ["outer" "inner"]}]
:out "captured stdout"
:err "captured stderr"}
Error assertions also include `:stacktrace`. A compact suite-scope entry
looks like:
{:var 'my.ns-test/a-test :ns 'my.ns-test :status :fail
:assertion-summary {:pass 0 :fail 1 :error 0}}
Custom result formatting
`:result-format` overrides returned keys and inclusions per scope. Scopes are
`:suite`, `:namespace`, and `:var`; each supports:
:top-level-keys top-level keys to return
:entry-keys keys to project for each result entry
:assertions? authoritative assertion gate; true adds `:assertions`,
false removes it
:output? authoritative output gate; true adds `:out`/`:err`,
false removes them
For example:
(run {:namespaces ['my.ns-test]
:result-format {:namespace {:top-level-keys [:summary :pass? :results]
:entry-keys [:var :status]
:assertions? true
:output? false}}})
If custom `:top-level-keys` omits both `:results` and `:failures`, helpers
such as `failures` return empty/nil values because there is no collection to
inspect.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 |