Closed didibus closed 5 years ago
Hey @didibus, thanks for taking the time to suggest this. It is always great to hear from a user of test-refresh.
What test-runner are you using?
My current thinking is this is a feature that probably won't get added and then supported forever since a similar goal can be achieve with the current implementation of test selectors.
Any reason why you don't use those?
Maybe I'm missing something about the test-selectors, but I thought they required you to add meta to your functions?
My build system test-runner uses filenames to distinguish integ from unit tests. So I need my lein setup to be the same. Is that achievable with test-selectors?
It is!
The test-selectors get the metadata map for the deftest
. This includes a :name
key that points towards the test symbol. Below is an example that would only run tests for symbols that contain "integration"
:test-selectors {:integration (fn [m]
(clojure.string/includes? (str (:name m))
"integration"))}
Let me know if something like that doesn't work out for you. If it doesn't, I'd be interested in digging deeper.
Below is a combination of selectors that would cause the default case to not run integration tests. It also adds looking at the namespace.
:test-selectors {:default (fn [m]
(not (or (clojure.string/includes? (str (:ns m)) "integration")
(clojure.string/includes? (str (:name m)) "integration"))))
:integration (fn [m]
(or (clojure.string/includes? (str (:ns m)) "integration")
(clojure.string/includes? (str (:name m)) "integration")))}
I have integration tests in some namespaces, where the way my test-runner knows to skip them based on a regex, which basically skip things with integ or integration in them.
Would be nice to have a similar option in the test-refresh map.