Skip to content
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

cider-test-run-tests fails to run tests unless tests are in a -test.clj file #784

Closed
hugoduncan opened this issue Sep 9, 2014 · 13 comments
Assignees

Comments

@hugoduncan
Copy link
Member

When trying to run clojure.test tests in a namespace that doesn't end in -test, cider-test-run-tests tries to locate the namespace named by the current buffer with -test appended.

This makes it unusable in such buffers. leiningen's tests do not follow this expected naming scheme for example.

@jeffvalk
Copy link
Contributor

The current approach is admittedly imperfect; it just accommodates the most common naming convention. Perhaps non-existence of a -test suffixed namespace should simply cause cider-test to run tests for the current namespace. @hugoduncan Thoughts?

@hugoduncan
Copy link
Member Author

That would work for me, as it just disables the convenience of running tests from an implementation namespace in this case.

@jeffvalk jeffvalk self-assigned this Sep 10, 2014
@scgilardi
Copy link

I think it would be useful to have a config option to specify a way to map to and vice-versa. I can imagine this being done using some kind of pattern string, perhaps a regex. Ideally it would have presets available for common conventions such as the current default and the leiningen default and a way to specify a custom pattern.

@bbatsov
Copy link
Member

bbatsov commented Sep 19, 2014

I think it would be useful to have a config option to specify a way to map to and vice-versa. I can imagine this being done using some kind of pattern string, perhaps a regex. Ideally it would have presets available for common conventions such as the current default and the leiningen default and a way to specify a custom pattern.

Perhaps. We tried to do something similar in clojure-mode at some point, but we decided it was not worth it, as there are some pretty crazy edge cases - you might decide to have several test namespaces for the same namespace or you might use inconsistent convention across your project.

Anyways, we'll think of something.

@jeremyheiler
Copy link
Contributor

+1 for being able to run the tests when in the test namespace.

@bbatsov
Copy link
Member

bbatsov commented Nov 10, 2014

Seems to me the best (and simplest) idea would be simply to prompt the user for the matching namespace and remember it for future test runs.

@bbatsov
Copy link
Member

bbatsov commented Nov 15, 2014

@hugoduncan Turned out we already had a way to customize this - cider-test-infer-test-ns.

@bbatsov
Copy link
Member

bbatsov commented Nov 15, 2014

I've also added prefix arg support for C-c , - with a prefix the command won't do any ns inference and will simply run the tests in the current ns. It's not the most refined solution, but it was an easy fix and solves the problem at hand.

Generally, most people will probably just customize cider-test-infer-test-ns.

@nicolasGuillouet
Copy link

ok, fine but how do you customize it in the init.el ? I would like the same behavior as before : running the current test file with C-c , ...

@nicolasGuillouet
Copy link

(setq cider-test-infer-test-ns (lambda (ns) ns)) is the best way ?

@bbatsov
Copy link
Member

bbatsov commented Jun 24, 2015

(setq cider-test-infer-test-ns (lambda (ns) ns)) is the best way ?

Looks good to me, although by doing this you won't be able to run the tests from ns they are related to.

@nicolasGuillouet
Copy link

I agree, perhaps it should be more useful to run from the related ns. I did like this because the previous behavior ...
Thanks

@felipegmarques
Copy link

Hi, I'm trying to set my cider-test-infer-test-ns, but I'm not sure where I should do. I'm using spacemacs.

Thanks, and sorry for the basic question.

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

No branches or pull requests

7 participants