Is there a good way to provide some initialization for a property when used with the clojure.test integration? For example, I have this code:
(defspec my-gen-test
100
(kafka/with-driver [d (make-driver {})]
(prop/for-all [record (my-record-gen)]
(kafka/pipe-input d record))))
It needs to initialize a Kafka test driver and then run the property test. with-driver
is basically the same as with-open
(i.e. it will close a resource after the form's body completes). The problem I'm running into is the property check doesn't appear to block until it's completed so the driver opens and then closes pretty quickly. Is there a way to work around this? Currently thinking to just make my own defspec
that can handle this sort of thing.I could write my own quick-check
fn like this:
(defn quick-check
[num-tests property & opts]
(tc-test/assert-check
(apply tc/quick-check num-tests property opts)))
@kenny you it to be opened/closed just once for the whole test run, across many trials?
Yes. Open at the beginning, close at the end.
It should run through all the properties using the same driver.
If you did it in a fixture and bound a dynamic var, would that be good enough?
Yes but fixtures are icky. They either run with each deftest
or only once. Neither of those choices are a good fit.
Oh right
Yeah I don't think there are any super clean options
That quick-check wrapper fn should work for now