Hi folks, hopefully this is the right channel for a question about test.chuck.
If I have the following namespace
(ns scratch
(:require [clojure.test :refer [deftest is]]
[clojure.test.check.generators :as gen]
[com.gfredericks.test.chuck.clojure-test :refer [checking]]))
(deftest foo
(checking "" [x gen/nat]
(is (= (* 2 x) (inc (+ x x))))))
(comment
(foo)
)
and run the (foo) form in the rich comment I get the following output
Tests failed, smallest case: [{x 0}]
Seed: 1769119952601
FAIL in (foo) (scratch.clj:8)
expected: (= (* 2 x) (inc (+ x x)))
actual: (not (= 0 1))
While this gives me all the information I need, I have been hacking the smallest failing case data into the test to start exploring the failure. This is more painful than I would like it to be when the smallest case contains a decent amount of data.
Am I missing a trick when it comes to running one of these tests with a specific set of data?
Or is this some functionality I should add myself?painful because ...
naively I imagine you are doing something like: (def data ...large...) (my-fun-used-in-checking data)
checking takes an option map that lets you pass the seed, so you can also repro the checking call (but it will run all the cases till the failure)
Painful because I would modify the test to be as follows
(deftest foo
(let [x 0]
(is (= (* 2 x) (inc (+ x x))))))
and then run the (foo) form. Writing it down makes me think it's not that much of a problem, but it definitely feels like a break of flow when the reproduction data is large.It doesn't seem like I'm missing anything. I'll have a play around with some ideas.
no, don't think there's any more help here. I would think about encapsulating those expressions into fns (may start to obscure the tests, not sure) to remove more of the copy/paste
depending on IDE, you may be able to capture some of the workflow into an extension. asking in your IDE-specific forum may lead to some ideas there
Awesome, good shout. Thanks.