com.walmartlabs.test-reporting
An extension for clojure.test that allows additional context to be output only when a test failure or error occurs.
*reported?
Used to prevent multiple reports of the context. This flag is set to true when *reporting-context* is bound with new data, and reset to false when the context is printed out.
*reporting-context*
dynamic
Contains a map of additional information to be printed in the report when a test failure or error is observed.
reporting
macro
(reporting data & forms)
Establishes a context in which certain data is printed when the form (tests using the is
macro) identify test failures or exceptions.
This adds keys to the *reporting-context*. After executing the forms, a check is made to see if the number of errors or failures changed; if so then the reporting context is pretty-printed to *out*
.
The data maybe a symbol: The unevaluated symbol becomes the key, and the evaluated symbol is the value.
Alternately, data may be a map, which is merged into the context. In this form, keys must be quoted if symbols.
(reporting request
(is ...))
is the same as:
(reporting {'request request}
(is ...))
A final alternative is to report a vector; each of the symbols is quoted.
(reporting [request response] ...)
is the same as:
(reporting {'request request 'response response} ...)
Nested usages of reporting is allowed; a reasonable attempt is made to prevent the context from being printed multiple times when there are multiple failures. Typically, the context is only printed once, at the deepest nested block in which test failures occur.
snapshot-counters
(snapshot-counters)
Returns just the :fail and :error keys from the *report-counters*
var. A change to either of these values indicates a test failure, triggering the reporting of context.