Skip to content

Commit 8caf4a0

Browse files
committed
Document the quick-check return value in detail.
1 parent 3638de3 commit 8caf4a0

File tree

2 files changed

+89
-3
lines changed

2 files changed

+89
-3
lines changed

src/main/clojure/clojure/test/check.cljc

+86-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,92 @@
9898
:result-data {...}
9999
:seed 42}
100100
101-
It will also be called on :complete, :shrink-step and :shrunk.
101+
It will also be called on :complete, :shrink-step and :shrunk. Many
102+
of the keys also appear in the quick-check return value, and are
103+
documented below.
104+
105+
If the test passes, the return value will be something like:
106+
107+
{:num-tests 100,
108+
:pass? true,
109+
:result true,
110+
:seed 1561826505982,
111+
:time-elapsed-ms 24}
112+
113+
If the test fails, the return value will be something like:
114+
115+
{:fail [0],
116+
:failed-after-ms 0,
117+
:failing-size 0,
118+
:num-tests 1,
119+
:pass? false,
120+
:result false,
121+
:result-data nil,
122+
:seed 1561826506080,
123+
:shrunk
124+
{:depth 0,
125+
:pass? false,
126+
:result false,
127+
:result-data nil,
128+
:smallest [0],
129+
:time-shrinking-ms 0,
130+
:total-nodes-visited 0}}
131+
132+
The meaning of the individual entries is:
133+
134+
:num-tests
135+
The total number of trials that was were run, not including
136+
shrinking (if applicable)
137+
138+
:pass?
139+
A boolean indicating whether the test passed or failed
140+
141+
:result
142+
A legacy entry that is similar to :pass?
143+
144+
:seed
145+
The seed used for the entire test run; can be used to reproduce
146+
a test run by passing it as the :seed option to quick-check
147+
148+
:time-elapsed-ms
149+
The total time, in milliseconds, of a successful test run
150+
151+
:fail
152+
The generated values for the first failure; note that this is
153+
always a vector, since prop/for-all can have multiple clauses
154+
155+
:failed-after-ms
156+
The total time, in milliseconds, spent finding the first failing
157+
trial
158+
159+
:failing-size
160+
The value of the size parameter used to generate the first
161+
failure
162+
163+
:result-data
164+
The result data, if any, of the first failing trial (to take
165+
advantage of this a property must return an object satisfying
166+
the clojure.test.check.results/Result protocol)
167+
168+
:shrunk
169+
A map of data about the shrinking process; nested keys that
170+
appear at the top level have the same meaning; other keys are
171+
documented next
172+
173+
:shrunk / :depth
174+
The depth in the shrink tree that the smallest failing instance
175+
was found; this is essentially the idea of how many times the
176+
original failure was successfully shrunk
177+
178+
:smallest
179+
The smallest values found in the shrinking process that still
180+
fail the test; this is a vector of the same type as :fail
181+
182+
:time-shrinking-ms
183+
The total time, in milliseconds, spent shrinking
184+
185+
:total-nodes-visited
186+
The total number of steps in the shrinking process
102187
103188
Examples:
104189

src/main/clojure/clojure/test/check/properties.cljc

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@
7474
side of each binding is a generator.
7575
7676
The body should be an expression of the generated values that will
77-
be tested for truthiness. Exceptions in the body will be caught and
78-
treated as failures.
77+
be tested for truthiness, unless it is a special implementation of
78+
the clojure.test.check.results/Result protocol. Exceptions in the
79+
body will be caught and treated as failures.
7980
8081
When there are multiple binding pairs, the earlier pairs are not
8182
visible to the later pairs.

0 commit comments

Comments
 (0)