-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
:test-selectors doesn't suppress clojure.test fixtures #1269
Comments
Seems to be related to http://dev.clojure.org/jira/browse/CLJ-866 which would provide a nicer hook. |
Given |
Yeah, removing |
You shouldn't need to hook |
The old method skipped tests by adding a hook to clojure.test/test-var, the problem being that :each fixtures associated with the test have already run at that point, which is unideal. This change skips test by removing their :test metadata before running the tests at all, which causes clojure.test to not see it as a test. We use ns-interns to enumerate the vars, the same way clojure.test does.
As noted in a leiningen issue[1], overriding test-var isn't an appropriate filtering approach, as it doesn't stop fixtures from running for the filtered-out tests. They pointed to a Clojure issue[2] that added the test-vars fn, which runs the fixtures only for the vars you pass in. However, they indicated later in that thread that while they waited for that issue to be resolved (which it is now), they would just remove the :test metadata from the vars. I haven't looked to confirm which approach they took, so not sure if I'm being consistent. The only drawback seems to be the lack of support fo the :test-ns-hook feature that allows you to control order. This doesn't seem like that great of a feature anyway, so I'm not too bothered. [1] technomancy/leiningen#1269 [2] http://dev.clojure.org/jira/browse/CLJ-866
Drive-by comment: I just ran into the |
Another drive-by comment. Also ran into exactly this today. Any possibilities or ideas to deal with this situation? I also have one clojure test file that only contains integration tests. Would be nice to not have it spin up dependencies... |
+1 I'm on |
This implementation is a mess; due to the fact that I would recommend moving to circleci.test going forward if you can instead of relying on a combination of the unmaintained |
Thanks for the advice @technomancy. I'll start using |
So, I've used However it doesn't appear to limit The fixtures are setup regardless of whether I |
The fixtures are setup regardless of whether I lein test or lein test :unit. Am I missing something, or is this simply not supported functionality and I should look at coding it up?
The circleci.test lib is still pretty new, so it's not surprising that
there are a few unexpected quirks.
I think this would be a good addition to the lib if you want to take a
shot at implementing it.
|
@technomancy Just stumbled onto this thread for more-or-less the same reason as the others - can you point to more about (or elaborate on) clojure.test being unmaintained? Thanks! |
You can check the commit history yourself. I've tried a number of times to get changes in, and it may have worked once, but mostly you just get ignored.
|
I know this is an old issue, this might help people that stumble into this these days, Ended up doing my setup and teardown in a bash script 🤷♂️, at least this let me run |
The implementation of
:test-selectors
hooksclojure.test/test-var
, which is responsible for running just the tests, not the fixtures.This means that, for example, if I have an
:each
fixture around a set of five tests that are all excluded by my:test-selectors
, the fixture will still run five times.Given that one use case for
:test-selectors
is to exclude tests that require some unavailable external resource, and a use case for fixtures is for managing external resources, this is rather inconvenient.One fix for just the
:each
fixtures is to stop hookingtest-var
and instead hooktest-all-vars
and for each var in the namespace remove the:test
metadata when the:test-selector
requires it.This doesn't address
:once
fixtures though, which seems much trickier.The text was updated successfully, but these errors were encountered: