This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-03
Channels
- # announcements (2)
- # babashka (66)
- # beginners (225)
- # braveandtrue (1)
- # calva (14)
- # circleci (1)
- # clj-kondo (36)
- # cljsrn (3)
- # clojure (423)
- # clojure-finland (7)
- # clojure-nl (1)
- # clojure-spec (14)
- # clojure-survey (41)
- # clojure-sweden (2)
- # clojure-uk (13)
- # clojurescript (59)
- # community-development (10)
- # cursive (2)
- # datascript (14)
- # datomic (63)
- # events (3)
- # expound (8)
- # figwheel-main (6)
- # kaocha (8)
- # luminus (6)
- # malli (1)
- # nrepl (2)
- # off-topic (51)
- # other-lisps (3)
- # reagent (16)
- # shadow-cljs (44)
- # spacemacs (7)
- # sql (22)
- # vrac (1)
I have a macro generating tests "on the fly", is there a way I can have Kaocha run only the tests by that macro? Adding a metadata key to the generated deftest does not work, I assume Kaocha is statically parsing and looking at the test files.
Hmm, I believe that adding the metadata should work. Are you sure your macro adds the metadata correctly, though? It's a bit tricky, If you do it like make-test-1
below, it won't work, but I think make-test-2
would work
(defmacro make-test-1 [n] `(deftest ^:my-test ~n))
(defmacro make-test-2 [n] `(deftest ~(with-meta n {:my-test true})))
You can check it in REPL by requiring the namespace with macro-generated tests and running (meta #'your-namespace/name-of-the-test)
. If the metadata is in the result, then Kaocha should see it.
@miikka is correct, your test files get loaded first, then we look for metadata on the vars. You can also check --print-test-plan to see the metadata Kaocha has found for each var