Fork me on GitHub
#testing
<
2023-02-02
>
cdeln13:02:00

Is there a nice way to check function specs in clojure.test? There is clojure.spec.test.alpha/check which does the job, is there any integration with clojure.test so that I can specify which functions to check and run them with lein test ?

seancorfield17:02:10

We tend to do stuff like:

(defexpect gen-tests
  (expect (more->
           true? :result
           true? :pass?)
          (from-each [check (st/check [`sut/add-line-number
                                       `sut/filter-settings
                                       `sut/line-number-set
                                       `sut/settings-line-number])]
            (:clojure.spec.test.check/ret check))))
(`st` is clojure.spec.test.alpha)

seancorfield17:02:48

(so, yeah, we call check directly on one or more functions and explicitly check the results in a deftest)

cdeln17:02:12

This is exactly what I am looking for. Looks convenient, you just keep adding stuff in that vector to be checked.