(async tm cb)Adds an event to the event queue with the specified time and callback function. Must be wrapped by with-timeline.
Adds an event to the event queue with the specified time and callback function. Must be wrapped by with-timeline.
(behavior & args)Adds a new string to the list of testing contexts. May be nested, but must occur inside a specification. If the behavior is not machine testable then include the keyword :manual-test just after the behavior name instead of code.
(behavior "blows up when the moon is full" :manual-test)
Adds a new string to the list of testing contexts. May be nested, but must occur inside a specification. If the behavior is not machine testable then include the keyword :manual-test just after the behavior name instead of code. (behavior "blows up when the moon is full" :manual-test)
(component & args)An alias for behavior. Makes some specification code easier to read where a given specification is describing subcomponents of a whole.
An alias for behavior. Makes some specification code easier to read where a given specification is describing subcomponents of a whole.
(generated-stub f)Returns a function that can behave just like f (which must be a symbol), but that will simply verify
arguments according to its :args spec and then return a value that conforms to that function's :ret spec.
Returns a function that can behave just like `f` (which must be a symbol), but that will simply verify arguments according to its `:args` spec and then return a value that conforms to that function's `:ret` spec.
(provided string & forms)A macro for using a Midje-style provided clause within any testing framework.
This macro rewrites assertion-style mocking statements into code that can do that mocking.
See the clojure.spec for ::p/mocks.
See the doc string for p/parse-arrow-count.
A macro for using a Midje-style provided clause within any testing framework. This macro rewrites assertion-style mocking statements into code that can do that mocking. See the clojure.spec for `::p/mocks`. See the doc string for `p/parse-arrow-count`.
(provided! description & forms)Just like provided, but forces mocked functions to conform to the spec of the original function (if available).
Just like `provided`, but forces mocked functions to conform to the spec of the original function (if available).
(provided!! description & args)Like provided!, but also verifies that all mocked functions have transitive test coverage.
First argument is the description string. Optionally accepts an options map as second argument
to override global settings from proof/configure!:
Examples: ;; Using global config (provided!! "database operations are mocked" (myapp.db/save! data) => {:id 1} (assertions (myapp.orders/create-order data) => {:id 1}))
;; With explicit options (provided!! "database operations are mocked" {:scope-ns-prefixes #{"myapp"}} (myapp.db/save! data) => {:id 1} (assertions (myapp.orders/create-order data) => {:id 1}))
Like provided!, but also verifies that all mocked functions have transitive test coverage.
First argument is the description string. Optionally accepts an options map as second argument
to override global settings from `proof/configure!`:
- :scope-ns-prefixes - set of namespace prefix strings for coverage checking
Examples:
;; Using global config
(provided!! "database operations are mocked"
(myapp.db/save! data) => {:id 1}
(assertions
(myapp.orders/create-order data) => {:id 1}))
;; With explicit options
(provided!! "database operations are mocked" {:scope-ns-prefixes #{"myapp"}}
(myapp.db/save! data) => {:id 1}
(assertions
(myapp.orders/create-order data) => {:id 1}))(set-hooks! handlers)Call this to set the :on-enter and :on-leave hooks.
Currently only specification, behavior, and component call these hooks.
:on-enter and :on-leave will be called with a single argument,
a map with the test or behavior string and its location (currently just line number).
See the macro source code for exact and up to date details.
Call this to set the `:on-enter` and `:on-leave` hooks. Currently only `specification`, `behavior`, and `component` call these hooks. `:on-enter` and `:on-leave` will be called with a single argument, a map with the test or behavior string and its location (currently just line number). See the macro source code for exact and up to date details.
(specification & args)Defines a specification which is translated into a what a deftest macro produces with report hooks for the description. Technically outputs a deftest with additional output reporting. When load-tests is false, the specification is ignored.
Usage: (specification "test name" ...) (specification "test name" :focus ...) (specification {:integration true} "test name" ...) (specification {:integration true :slow true} "test name" :focus ...) (specification {:covers {`my.ns/fn-under-test "a1b2c3"}} "test name" ...)
An optional metadata map can appear before the test name to add custom metadata to the test var. Keyword selectors (like :focus) can follow the test name and are converted to metadata (e.g., {:focus true}). Both metadata sources are merged, with selector keywords taking precedence over the metadata map.
The :covers key in metadata declares which functions this test covers and their sealed signatures. This enables transitive test coverage verification with staleness detection.
Format: {:covers {fn-symbol "signature"}}
Get signatures using: (fulcro-spec.signature/signature 'my.ns/fn scope-ns-prefixes)
The signature function automatically returns:
Legacy format (no staleness detection): {:covers [fn-afn-b]}
Auto-skip support: When -Dfulcro-spec.auto-skip=true is set and all covered functions have matching signatures, the test body is replaced with a simple passing assertion. For fast full-suite runs, also set -Dfulcro-spec.sigcache=true
Defines a specification which is translated into a what a deftest macro produces with report hooks for the
description. Technically outputs a deftest with additional output reporting.
When *load-tests* is false, the specification is ignored.
Usage:
(specification "test name" ...)
(specification "test name" :focus ...)
(specification {:integration true} "test name" ...)
(specification {:integration true :slow true} "test name" :focus ...)
(specification {:covers {`my.ns/fn-under-test "a1b2c3"}} "test name" ...)
An optional metadata map can appear before the test name to add custom metadata to the test var.
Keyword selectors (like :focus) can follow the test name and are converted to metadata (e.g., {:focus true}).
Both metadata sources are merged, with selector keywords taking precedence over the metadata map.
The :covers key in metadata declares which functions this test covers and their sealed signatures.
This enables transitive test coverage verification with staleness detection.
Format: {:covers {fn-symbol "signature"}}
- fn-symbol: Quoted symbol of the function being tested
- signature: The function's signature (see fulcro-spec.signature/signature)
Get signatures using:
(fulcro-spec.signature/signature 'my.ns/fn scope-ns-prefixes)
The signature function automatically returns:
- Single-field "xxxxxx" for leaf functions (no in-scope callees)
- Two-field "xxxxxx,yyyyyy" for non-leaf functions (has callees)
Legacy format (no staleness detection): {:covers [`fn-a `fn-b]}
Auto-skip support:
When -Dfulcro-spec.auto-skip=true is set and all covered functions have
matching signatures, the test body is replaced with a simple passing
assertion. For fast full-suite runs, also set -Dfulcro-spec.sigcache=true(tick tm)Advances the timer by the specified number of ticks. Must be wrapped by with-timeline.
Advances the timer by the specified number of ticks. Must be wrapped by with-timeline.
(when-mocking & forms)A macro that works just like 'provided', but requires no string and outputs no extra text in the test output.
See the clojure.spec for ::p/mocks.
See the doc string for p/parse-arrow-count.
A macro that works just like 'provided', but requires no string and outputs no extra text in the test output. See the clojure.spec for `::p/mocks`. See the doc string for `p/parse-arrow-count`.
(when-mocking! & forms)Just like when-mocking, but forces mocked functions to conform to the spec of the original function (if available).
Just like when-mocking, but forces mocked functions to conform to the spec of the original function (if available).
(when-mocking!! & args)Like when-mocking!, but also verifies that all mocked functions have transitive test coverage. This enforces that you're building a complete proof chain.
Uses global config from proof/configure!. Optionally accepts an options map as first argument
to override global settings:
Examples: ;; Using global config (set via proof/configure!) (when-mocking!! (myapp.db/save! data) => {:id 1} (assertions (myapp.orders/create-order data) => {:id 1}))
;; With explicit options (overrides global config) (when-mocking!! {:scope-ns-prefixes #{"myapp"}} (myapp.db/save! data) => {:id 1} (assertions (myapp.orders/create-order data) => {:id 1}))
Like when-mocking!, but also verifies that all mocked functions have transitive test coverage.
This enforces that you're building a complete proof chain.
Uses global config from `proof/configure!`. Optionally accepts an options map as first argument
to override global settings:
- :scope-ns-prefixes - set of namespace prefix strings for coverage checking
Examples:
;; Using global config (set via proof/configure!)
(when-mocking!!
(myapp.db/save! data) => {:id 1}
(assertions
(myapp.orders/create-order data) => {:id 1}))
;; With explicit options (overrides global config)
(when-mocking!! {:scope-ns-prefixes #{"myapp"}}
(myapp.db/save! data) => {:id 1}
(assertions
(myapp.orders/create-order data) => {:id 1}))(with-timeline & forms)Adds the infrastructure required for doing timeline testing
Adds the infrastructure required for doing timeline testing
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 |