(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
:args [...]
:num-tests <number of tests run so far>
:num-tests-total <total number of tests to be run>
:seed 42
:pass? true
:property #<...>
:result true
:result-data {...}}
;; called after the first failing trial
{:type :failure
:fail [...failing args...]
:failing-size 13
:num-tests <tests ran before failure found>
:pass? false
:property #<...>
:result false/exception
:result-data {...}
:seed 42}
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 :args [...] :num-tests <number of tests run so far> :num-tests-total <total number of tests to be run> :seed 42 :pass? true :property #<...> :result true :result-data {...}} ;; called after the first failing trial {:type :failure :fail [...failing args...] :failing-size 13 :num-tests <tests ran before failure found> :pass? false :property #<...> :result false/exception :result-data {...} :seed 42} 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