For generative testing, is it a good idea to do stest/check
on your functions as part of CI? If so, is there a common way to included them in your deftest
's so they get called?
Yes, Kaocha has first class support for this, it might still need improving though. If you have feedback please drop into #kaocha. Same thing for the Cirlce CI orb.
I have a little helper function for doing this.
(defn check-ns-fdefs
([ns-sym-or-syms]
(check-ns-fdefs ns-sym-or-syms 1000))
([ns-sym-or-syms num-tests]
(let [summary (-> (stest/enumerate-namespace ns-sym-or-syms)
(stest/check {:clojure.spec.test.check/opts
{:num-tests num-tests}})
stest/summarize-results)]
(is (= (:total summary) (:check-passed summary))
"generative check test failed, see output for details"))))
and then in a test namespace i can use
(deftest check-fdefs
(check-ns-fdefs 'some.namespace 100))
not a perfect integration but does the job
Thanks, stealing this!
Apparently kaocha test runner will run specifications automatically, so this could be used as your test runner in the CI environment. https://cljdoc.org/d/lambdaisland/kaocha/1.0.632/doc/automatic-spec-test-check-generation Next weekl I'm going to try kaocha locally to run spec and then try kaocha on CircleCI. CircleCI has a kaocha orb which is a simple way to add common functionality to a build https://circleci.com/orbs/registry/orb/lambdaisland/kaocha
Nice, look forward to it!