testing

Janne Sauvala 2020-07-04T08:52:53.053400Z

@janne.sauvala has joined the channel

hugo 2020-07-04T10:58:19.053600Z

@hybas3 has joined the channel

practicalli-johnny 2020-07-04T12:44:33.053800Z

@jr0cket has joined the channel

Joe 2020-07-04T13:17:06.054Z

@allaboutthatmace1789 has joined the channel

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?

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

Thanks, stealing this!

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

practicalli-johnny 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!

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
Zoltan Kalmar 2020-07-04T20:19:06.057900Z

@kalmiz has joined the channel

2020-07-04T05:49:32.053200Z

@sogaiu has joined the channel