Multiplexing test.check
property and tracking failure.
See README for overview.
Multiplexing `test.check` property and tracking failure. See README for overview.
(and & form+)
Like Clojure's and
but an item consider truthy if it passes clojure.test.check.results/pass?
.
Great match for check
as it allows for testing several assertions, even nested one, while keepin track
of where failure happens.
Like Clojure's `and` but an item consider truthy if it passes `clojure.test.check.results/pass?`. Great match for [[check]] as it allows for testing several assertions, even nested one, while keepin track of where failure happens.
(check beacon form)
Executes form.
Any failure or exception is wrapped in an object that satifies clojure.test.check.results/Result
.
The data attached is a map such as:
Key | Value |
---|---|
:mprop/path | List of beacon s, contains more than one if checks were nested and shows exactly where failure happened |
:mprop/value | Value returned by form |
Usually, checks are used with and
. A beacon
can be any value the user deems useful.
For example (and
being and
from this namespace):
(and (check "Some test"
(= 4 (+ 2 2)))
(check "Another test"
(= 3 (inc 1))))
Executes form. Any failure or exception is wrapped in an object that satifies `clojure.test.check.results/Result`. The data attached is a map such as: | Key | Value | |---|---| | `:mprop/path` | List of `beacon`s, contains more than one if checks were nested and shows exactly where failure happened | | `:mprop/value` | Value returned by `form` | Usually, checks are used with [[and]]. A `beacon` can be any value the user deems useful. For example (`and` being [[and]] from this namespace): ```clojure (and (check "Some test" (= 4 (+ 2 2))) (check "Another test" (= 3 (inc 1)))) ```
(deftest sym prop)
(deftest sym option+ prop)
Like clojure.test.check.clojure-test/defspec
.
Difference is that the number of tests and maximum size can be easily configured and calibrated at the level of the whole test suite.
option+
is a map as accepted by defspec
, it can notably hold :max-size
and
:num-tests
.
Most of the time, it is not productive fixing absolute values. During dev, number of tests and maximum size can be kept low in order to gain a fast feedback on what is going on. During actual testing, those values can be set a lot higher.
For altering the base values, see max-size
and num-tests
. Each test can be
calibrated against those base values. option+
also accepts:
Key | Value |
---|---|
:ratio-num | Multiplies the base num-tests value |
:ratio-size | Multiplies the base max-size value |
For instance, a test that runs 10 times more with half the maximum size:
(deftest foo
{:ratio-num 10
:ratio-size 0.5}
some-property)
Like `clojure.test.check.clojure-test/defspec`. Difference is that the number of tests and maximum size can be easily configured and calibrated at the level of the whole test suite. `option+` is a map as accepted by `defspec`, it can notably hold `:max-size` and `:num-tests`. Most of the time, it is not productive fixing absolute values. During dev, number of tests and maximum size can be kept low in order to gain a fast feedback on what is going on. During actual testing, those values can be set a lot higher. For altering the base values, see [[max-size]] and [[num-tests]]. Each test can be calibrated against those base values. `option+` also accepts: | Key | Value | |---|---| | `:ratio-num` | Multiplies the base [[num-tests]] value | | `:ratio-size` | Multiplies the base [[max-size]] value | For instance, a test that runs 10 times more with half the maximum size: ```clojure (deftest foo {:ratio-num 10 :ratio-size 0.5} some-property) ```
(fail beacon failure)
Used by check
.
More rarely, can be used to return an explicit failure.
Used by [[check]]. More rarely, can be used to return an explicit failure.
Maximum size used by deftest
. Can be set using the "MPROP_MAX_SIZE" env variable.
Default value is 200.
Maximum size used by [[deftest]]. Can be set using the "MPROP_MAX_SIZE" env variable. Default value is 200.
(mult & check+)
Very common, sugar for using check
with and
.
Short for "multiplex".
Replicating example in check
:
(mult "Some test"
(= 4 (+ 2 2))
"Another test"
(= 3 (inc 1)))
Very common, sugar for using [[check]] with [[and]]. Short for "multiplex". Replicating example in [[check]]: ```clojure (mult "Some test" (= 4 (+ 2 2)) "Another test" (= 3 (inc 1))) ```
Number of tests used by deftest
. Can be set using the "MPROP_NUM_TESTS" env variable.
Default value is 100.
Number of tests used by [[deftest]]. Can be set using the "MPROP_NUM_TESTS" env variable. Default value is 100.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close