gfredericks / test.chuck

A utility library for test.check
Eclipse Public License 1.0
214 stars 26 forks source link

Unable to set `:seed` when using `checking` #48

Closed bhb closed 7 years ago

bhb commented 7 years ago

If checking fails, it fails prints the message:

Seed 1469058357988

However, unlike defspec, it isn't possible to pass the seed to checking to make it run the same series of tests.

Would you be interested in a PR that adds a version of checking that accepted a full set of quick-check options? That is, not only :seed, but also :max-size and :reporter-fn?

To preserve backwards compatibility, I think checking would need to have two forms. The old form would work as normal:

(deftest a-failing-test
  (checking "all ints lt 5" 100
    [i gen/int]
    (is (< i 5))))

but the new form would replace the integer with a map for all options

(deftest a-failing-test
  (checking "all ints lt 5" {:num-tests 100 :seed 1469058357988}
    [i gen/int]
    (is (< i 5))))
gfredericks commented 7 years ago

That sounds reasonable to me; that exact pattern is used in test.check itself somewhere I think

nberger commented 7 years ago

I could have used this a few weeks ago, so :+1: