(quick-check num-tests
property
&
{:keys [seed max-size reporter-fn]
:or {max-size 200 reporter-fn (constantly nil)}})
Tests property
num-tests
times.
Takes several optional keys:
:seed
Can be used to re-run previous tests, as the seed used is returned
after a test is run.
:max-size
.
can be used to control the 'size' of generated values. The size will
start at 0, and grow up to max-size, as the number of tests increases.
Generators will use the size parameter to bound their growth. This
prevents, for example, generating a five-thousand element vector on
the very first test.
:reporter-fn
A callback function that will be called at various points in the test
run, with a map like:
;; called after a passing trial
{:type :trial
:property #<...>
:so-far <number of tests run so far>
:num-tests <total number of tests>}
;; called after each failing trial
{:type :failure
:property #<...>
:result ...
:trial-number <tests ran before failure found>
:failing-args [...]}
It will also be called on :complete, :shrink-step and :shrunk.
Examples:
(def p (for-all [a gen/pos-int] (> (* a a) a)))
(quick-check 100 p)
(quick-check 200 p
:seed 42
:max-size 50
:reporter-fn (fn [m]
(when (= :failure (:type m))
(println "Uh oh..."))))
Tests `property` `num-tests` times. Takes several optional keys: `:seed` Can be used to re-run previous tests, as the seed used is returned after a test is run. `:max-size`. can be used to control the 'size' of generated values. The size will start at 0, and grow up to max-size, as the number of tests increases. Generators will use the size parameter to bound their growth. This prevents, for example, generating a five-thousand element vector on the very first test. `:reporter-fn` A callback function that will be called at various points in the test run, with a map like: ;; called after a passing trial {:type :trial :property #<...> :so-far <number of tests run so far> :num-tests <total number of tests>} ;; called after each failing trial {:type :failure :property #<...> :result ... :trial-number <tests ran before failure found> :failing-args [...]} It will also be called on :complete, :shrink-step and :shrunk. Examples: (def p (for-all [a gen/pos-int] (> (* a a) a))) (quick-check 100 p) (quick-check 200 p :seed 42 :max-size 50 :reporter-fn (fn [m] (when (= :failure (:type m)) (println "Uh oh..."))))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close