(->ex-failed expr data)
(->ex-failed _form expr data)
Useful for all expectations. Sets the base properties on the ExpectationFailed.
Useful for all expectations. Sets the base properties on the ExpectationFailed.
(cause-seq throwable)
Given a Throwable, returns a sequence of causes. The first element of the sequence is the given throwable itself.
Given a Throwable, returns a sequence of causes. The first element of the sequence is the given throwable itself.
(causes-with-msg? c re f)
Calls f with no arguments; catches exceptions with an instance of class c in their cause chain. If the message of the causing exception does not match re (with re-find), throws ExpectationFailed. Any non-matching exception will be re-thrown. Returns false if f throws no exceptions.
Useful in expect-it
or expect
.
Calls f with no arguments; catches exceptions with an instance of class c in their cause chain. If the message of the causing exception does not match re (with re-find), throws ExpectationFailed. Any non-matching exception will be re-thrown. Returns false if f throws no exceptions. Useful in `expect-it` or `expect`.
(causes? c f)
Calls f with no arguments; returns true if it throws an exception whose cause chain includes an instance of class c. Any other exception will be re-thrown. Returns false if f throws no exceptions.
Useful in expect-it
or expect
.
Calls f with no arguments; returns true if it throws an exception whose cause chain includes an instance of class c. Any other exception will be re-thrown. Returns false if f throws no exceptions. Useful in `expect-it` or `expect`.
(defdescribe test-name & children)
(defdescribe test-name doc? attr-map? & children)
describe
helper that assigns a describe
call to a Var of the given name.
test-name is a symbol.
doc (optional) is a documentation string. Unlike the other helpers, this doc must be a string literal.
attr-map (optional) is a metadata map.
children are test cases (see 'it') or nested test suites (see 'describe').
`describe` helper that assigns a `describe` call to a Var of the given name. test-name is a symbol. doc (optional) is a documentation string. Unlike the other helpers, this doc must be a string literal. attr-map (optional) is a metadata map. children are test cases (see 'it') or nested test suites (see 'describe').
(describe doc & children)
(describe doc attr-map? & children)
Defines a suite of tests.
doc is a documentation string expression. If the expression is a local, it will be used as is. If the expression is a resolvable symbol, it will be resolved and used as a var. Otherwise, it's evaluated like normal.
attr-map (optional) is a metadata map.
children are test cases or nested test suites.
Defines a suite of tests. doc is a documentation string expression. If the expression is a local, it will be used as is. If the expression is a resolvable symbol, it will be resolved and used as a var. Otherwise, it's evaluated like normal. attr-map (optional) is a metadata map. children are test cases or nested test suites.
(expect expr)
(expect expr msg)
Evaluates expression. If it returns logical true, returns that result. If the expression returns logical false, throws lazytest.ExpectationFailed with an attached map describing the reason for failure. Metadata on expr and on the 'expect' form itself will be merged into the failure map.
Evaluates expression. If it returns logical true, returns that result. If the expression returns logical false, throws lazytest.ExpectationFailed with an attached map describing the reason for failure. Metadata on expr and on the 'expect' form itself will be merged into the failure map.
(expect-it doc expr)
(expect-it doc sym? attr-map? expr)
Defines a single test case that wraps the given expr in an expect
call.
doc is a documentation string expression. If the expression is a local, it will be used as is. If the expression is a resolvable symbol, it will be resolved and used as a var. Otherwise, it's evaluated like normal.
attr-map (optional) is a metadata map
expr is a single expression, which must return logical true to indicate the test case passes or logical false to indicate failure.
Defines a single test case that wraps the given expr in an `expect` call. doc is a documentation string expression. If the expression is a local, it will be used as is. If the expression is a resolvable symbol, it will be resolved and used as a var. Otherwise, it's evaluated like normal. attr-map (optional) is a metadata map expr is a single expression, which must return logical true to indicate the test case passes or logical false to indicate failure.
(given bindings & body)
Like 'let' but returns the expressions of body in a vector. Suitable for nesting inside 'describe'.
Like 'let' but returns the expressions of body in a vector. Suitable for nesting inside 'describe'.
(it doc & body)
(it doc sym? attr-map? & body)
Defines a single test case that may execute arbitrary code.
doc is a documentation string expression. If the expression is a local, it will be used as is. If the expression is a resolvable symbol, it will be resolved and used as a var. Otherwise, it's evaluated like normal.
attr-map (optional) is a metadata map
body is any code, which must throw an exception (such as with 'expect') to indicate failure. If the code completes without throwing any exceptions, the test case has passed.
NOTE: Because failure requires an exception, no assertions after the thrown exception will be run.
Defines a single test case that may execute arbitrary code. doc is a documentation string expression. If the expression is a local, it will be used as is. If the expression is a resolvable symbol, it will be resolved and used as a var. Otherwise, it's evaluated like normal. attr-map (optional) is a metadata map body is any code, which must throw an exception (such as with 'expect') to indicate failure. If the code completes without throwing any exceptions, the test case has passed. NOTE: Because failure requires an exception, no assertions after the thrown exception will be run.
(ok? f)
Calls f with no arguments and discards its return value. Returns true if f does not throw any exceptions. Use when checking an expression that returns a logical false value.
Useful in expect-it
or expect
.
Calls f with no arguments and discards its return value. Returns true if f does not throw any exceptions. Use when checking an expression that returns a logical false value. Useful in `expect-it` or `expect`.
(throws-with-msg? c re f)
Calls f with no arguments; catches exceptions of class c. If the message of the caught exception does not match re (with re-find), throws ExpectationFailed. Any other exception not of class c will be re-thrown. Returns false if f throws no exceptions.
Useful in expect-it
or expect
.
Calls f with no arguments; catches exceptions of class c. If the message of the caught exception does not match re (with re-find), throws ExpectationFailed. Any other exception not of class c will be re-thrown. Returns false if f throws no exceptions. Useful in `expect-it` or `expect`.
(throws? c f)
Calls f with no arguments; returns true if it throws an instance of class c. Any other exception will be re-thrown. Returns false if f throws no exceptions.
Useful in expect-it
or expect
.
Calls f with no arguments; returns true if it throws an instance of class c. Any other exception will be re-thrown. Returns false if f throws no exceptions. Useful in `expect-it` or `expect`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close