testing

Testing tools, testing philosophy & methodology...
Joe 2020-07-04T14:58:54.056600Z

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?

plexus 2020-07-07T04:03:49.059Z

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.

👍 1
robertfw 2020-07-08T20:07:27.059500Z

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))

robertfw 2020-07-08T20:08:24.059700Z

not a perfect integration but does the job

Joe 2020-07-10T10:14:05.060100Z

Thanks, stealing this!

practicalli-john 2020-07-04T16:44:24.056800Z

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

😲 1
Joe 2020-07-04T17:30:40.057600Z

Nice, look forward to it!