New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to filter out test namespaces with regex #78

Closed
didibus opened this Issue Jan 17, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@didibus
Copy link

didibus commented Jan 17, 2019

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.

@jakemcc

This comment has been minimized.

Copy link
Owner

jakemcc commented Jan 17, 2019

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?

@didibus

This comment has been minimized.

Copy link
Author

didibus commented Jan 18, 2019

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?

@jakemcc

This comment has been minimized.

Copy link
Owner

jakemcc commented Jan 21, 2019

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

@jakemcc jakemcc closed this Jan 21, 2019

@jakemcc jakemcc reopened this Jan 21, 2019

@jakemcc

This comment has been minimized.

Copy link
Owner

jakemcc commented Jan 21, 2019

Let me know if something like that doesn't work out for you. If it doesn't, I'd be interested in digging deeper.

@jakemcc jakemcc closed this Jan 28, 2019

@jakemcc

This comment has been minimized.

Copy link
Owner

jakemcc commented Jan 28, 2019

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")))}
@jakemcc

This comment has been minimized.

Copy link
Owner

jakemcc commented Jan 29, 2019

Wrote up a blog post talking about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment