This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-24
Channels
- # aleph (5)
- # announcements (18)
- # babashka (3)
- # babashka-sci-dev (56)
- # beginners (56)
- # biff (5)
- # calva (27)
- # cider (20)
- # clj-commons (2)
- # clj-kondo (17)
- # cljsrn (18)
- # clojure (41)
- # clojure-europe (24)
- # clojure-nl (1)
- # clojure-serbia (1)
- # clojure-uk (15)
- # clojured (1)
- # clojurescript (40)
- # cursive (39)
- # datahike (2)
- # datalevin (4)
- # datascript (5)
- # emacs (23)
- # events (2)
- # figwheel-main (3)
- # inf-clojure (1)
- # instaparse (23)
- # introduce-yourself (3)
- # jobs (3)
- # jobs-discuss (13)
- # joyride (1)
- # juxt (10)
- # malli (21)
- # nbb (29)
- # off-topic (18)
- # pathom (29)
- # polylith (11)
- # project-updates (1)
- # proletarian (1)
- # rdf (2)
- # re-frame (4)
- # reitit (2)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (52)
- # tools-deps (57)
- # xtdb (32)
I am having a problem with testing using CIDER while testing. Every time I run a test in the project I am working on I get something to the effect of:
java.io.FilenotFoundException: Could not local my_project/test__init.class, my_project/test.clj on classpath at clojure.lang.RT.load ...
Could this have something to do with the version of nrepl
= 0.8.3 or cider-nrepl
= 0.25.5 that I am on?
I am using deps.edn
and not LeiningenTest namespace = test-project.test
Filename = test.clj
It says Could not local my_project/test__init.class, my_project/test.clj on classpath
so it's apparently looking for my-project.test
ns.
A few more tips/questions: • double check the namespace of the test you are running • how exactly are you running the test (which cider command?) • does it work with some other tests / test namespaces? • can you share the test or even the project? if not, perhaps you can create an isolated reproducer?
also check that the test code is on the class path Take a look at https://practical.li/clojure/testing/unit-testing/ to see a common approach to structuring unit tests in clojure
Im not sure how to determine this. How would I do that?
they appear not to be. but your tests are most likely under test
directory. Common to have that path under an alias that adds them. In your deps.edn do you have a :extra-paths ["test"]
or something equivalent?
I do have an :extra-paths ["test"]
entry but I just went and looked at the test
directory and the tests are actually in a subdirectory called integration
. I am guessing I need to specify that somehow in the :extra-paths
vector? Something like :extra-paths ["test/integratioh"]
?
Grep for defcustom cider-clojure-cli
here as well, understanding these is important for tools.deps users https://github.com/clojure-emacs/cider/blob/master/cider.el
No need to read the cider code (and one of those cli values is deprecated, so shouldn't be used).
The cider-jack-in command can be edited by using C-u
before calling the command/key binding
Or create a .dir-locals.el file and use cider-clojure-cli-aliases
to define aliases to include when calling cider-jack-in
https://practical.li/spacemacs/clojure-projects/project-configuration.html
No need to read the cider code
is bit of an overstatement though - defcustom declarations are documentation!
Also I can't find a make-obsolete-variable
for one of those variables - maybe something could be improved?
I've added the "`test/integration"` entry to the :extra-paths
vector and there was no change. I took your advice and used C-u
before cider-jack-in
and saw that looks every different from my deps.edn
. I am beginning to suspect I might not be following the right workflow:
I am:
1. cider-jack-in
2. cider-load-all-project-ns
3. Navigating to the test file
4. C-c C-t t to run individual test
Is there something I have to do differently when I jack in in order to use the deps.edn
configuration?Or am I missing a step? I do that same workflow for our other projects and it seems to work fine
no it uses the deps.edn to understand your project. My suggestion. ignore cider. start a repl from a command line. get to a point where you can • start the repl (`clj -A:<whatever-aliases-you-need`) • require the test namespace (`(require 'my.namespace-test)`) • get in the test namespace (`(in-ns 'my-namespace-test)`) • run the tests there (`(clojure.test/run-tests)`) Once you can achieve all of these, you will understand what CIDER needs in order to run the tests. And if any of these steps fail, you know that CIDER would fail similarly.
once this works • start up CIDER. Did you need to add any aliases to ensure your test namespaces were on the classpath? You’ll need to add them for CIDER • then just go to the test namespace you are interested in and require it • try running ns tests at this point
I got things to work in Calva but still no luck with Emacs. I will revisit this with Emacs when I have time. The same problem was happening with Calva until I used the right click and Load Current File and Dependencies. After I did that the tests worked fine. Is there an analog to this in Emacs that I can try?
Still nothing. I am just going to go with Calva for now but will revisit this. Thanks all for the help!