test-check

2016-08-02T12:59:02.000136Z

is there a good resource to help understand shrinking; how it works, what to consider etc...

2016-08-02T12:59:35.000137Z

it seems like quite an involved topic

lucasbradstreet 2016-08-02T13:29:18.000138Z

I’m interested in this. I have a reasonable intuition about it, but I’d like something in more detail

2016-08-02T14:01:04.000139Z

well I can answer specific questions about it at least

2016-08-02T14:01:48.000140Z

for the most part the shrinking strategy mirrors the structure of your generator

2016-08-02T14:02:21.000141Z

e.g., tuple shrinks by shrinking its elements; collections shrink by deleting elements and shrinking elements

2016-08-02T14:02:39.000142Z

fmap shrinks by shrinking the underlying element and running it through the function again

2016-08-02T14:09:55.000143Z

bind is a little weird though, and therefore so is gen/let

2016-08-02T15:04:11.000144Z

@alexmiller: regarding the test.check issue described in CLJ-1997, I'm considering pasting all the relevant code from riddley into test.check as the most practical option. I'm wondering if you see any problems with doing something like that for a contrib library.

mattly 2016-08-02T17:54:18.000145Z

I've started moving away from generators like gen/frequency that don't shrink in favor of those that provide predictable shrinking behavior such as gen/one-of

mattly 2016-08-02T17:55:10.000146Z

the idea being that when there are multiple possible values that require different generators, it will shrink along an axis of my choosing

mattly 2016-08-02T17:57:32.000147Z

for example, I have a node on the tree structure I generate where most of the time the value is an element from a collection, but sometimes it's not – however for most of the problems I encounter, that doesn't matter

mattly 2016-08-02T17:57:38.000148Z

so I setup the generator like so:

mattly 2016-08-02T17:58:37.000150Z

instead of using gen/frequency to mimic the structure of my inputs

mattly 2016-08-02T17:59:09.000151Z

it will definitely test the case where there's a thing, but will shrink towards there not being a thing

mattly 2016-08-02T17:59:20.000152Z

which reduces the noise I have to contend with when troubleshooting a failure

mattly 2016-08-02T18:00:56.000153Z

in some cases where things is a fixed size, I actually use gen/one-of to force a shrinking preference, since gen/elements is always random; you'd have to shrink the size of the input if you wanted predictability

mattly 2016-08-02T18:01:43.000154Z

(and feel free to correct me if I'm wrong – I'm going off of observation from usage and cursory readings of the code)

2016-08-02T18:11:08.000155Z

@mattly: what makes you say gen/frequency doesn't shrink?

2016-08-02T18:12:01.000156Z

oh I see; I'm inclined to say that's a bug

mattly 2016-08-02T18:12:14.000157Z

@gfredericks: my experience of using it, that example before, the frequencies didn't seem to matter when shrinking

2016-08-02T18:12:44.000158Z

I would think it should shrink toward earlier generators like one-of does

mattly 2016-08-02T18:12:57.000159Z

so f.e. [[3 (gen/return nil)] [1 (gen/elements things)]] it'll still pick gen/elements

mattly 2016-08-02T18:13:00.000160Z

that'd be even better

2016-08-02T18:13:38.000161Z

would you like to file the bug or shall I?

mattly 2016-08-02T18:14:09.000162Z

go for it, i don't think I have an account on the jira

mattly 2016-08-02T18:14:14.000163Z

I probably should

mattly 2016-08-02T18:14:23.000164Z

and you'd know more about what to say about it 😄

2016-08-02T18:18:03.000165Z

@mattly: http://dev.clojure.org/jira/browse/TCHECK-114

👍 1
mattly 2016-08-02T18:18:42.000166Z

I'm planning to do a writeup on my usage of test.check and property-based testing on the system I'm working on

mattly 2016-08-02T18:19:19.000167Z

there's a lot of material out there on what it is, but very little on how to use it effectively

mattly 2016-08-02T18:21:00.000168Z

this has been such a success on my system, I'm teaching our QA guy how to write generators

2016-08-02T18:22:46.000169Z

nice