This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-02
Channels
- # announcements (2)
- # aws (7)
- # babashka (47)
- # beginners (54)
- # biff (6)
- # calva (14)
- # clojure-europe (7)
- # clojure-germany (2)
- # clojure-japan (4)
- # clojure-norway (5)
- # datalevin (1)
- # deps-new (13)
- # helix (5)
- # hoplon (1)
- # hyperfiddle (12)
- # introduce-yourself (6)
- # joyride (1)
- # malli (2)
- # off-topic (21)
- # polylith (11)
- # re-frame (3)
- # reitit (8)
- # remote-jobs (1)
- # scittle (25)
- # shadow-cljs (20)
- # vim (19)
- # xtdb (4)
Hello! Is there something I need to do used the normal Emacs/CIDER workflow to run component tests? E.g. I'm able to execute cider-test-run-test
from emacs but the test never runs. The same behaviour happens in the real world demo app when I pull it down and try to run some of the example tests, so I guess it's not something unique to my project. I'm running the REPL from the commandline:
clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.5.3"}}}' -M:dev -m nrepl.cmdline
And then using:
cider-connect-clj
I heavily execute tests directly during development using CIDER so I'd prefer not to have to run the poly tool to execute them 🙂The poly
tool can help detect which components are changed since the last stable point and run tests incrementally. It has a built-in test runner and support for providing your own test runner to benefit from incremental testing.
During local development, I also use this approach and let the poly
tool run the test most of the time, although, sometimes, I run the test directly from Calva. I do not have any particular setup; as long as the test sources are in the classpath when the REPL is started, I can use Calva’s test runner without any issues. When Calva starts the REPL for me, it includes the`:dev` and :test
aliases from the workspace deps.edn
; hence all the test namespaces load into the REPL session.
I’ve tested it just now in Calva with the RealWorld example and found no issues. I do not have any experience with CIDER, so the only direction I can give you is to make sure the test namespaces are included in the REPL session (aka :test
alias).
It could be as simple as adding :test
alias here:
clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.5.3"}}}' -M:dev:test -m nrepl.cmdline
I use VS Code/Calva and have hot keys to execute current test (at cursor), all tests in the current (test) namespace, and all tests in the associated namespace (executes the test ns for the current src ns). That all works fine with Polylith.
But I've no idea what assumptions CIDER makes about how to run tests.
Ah! Figured it out. I normally jack into cider from emacs, but for this project have been starting REPL from the CLI to include the aliases for this project. Turns out I wasn't using the CIDER nrepl middleware when starting up that REPL, and adding those arguments in now has it working. You both pointed me in the right direction with the aliases though, so thanks for the support! 🙂
Cool! I mostly start my REPLs from the command line with a long list of aliases - so much so that I have a script to start my main work REPL in a Polylith project!
The cider middleware is in one of my aliases.
Thanks for this thread. It was really helpful. I was having a bear of a time trying to play around in the REPL when components were pulling in dependencies that the root project didn't need. C-u C-c M-j
to jack in, then add :dev:test
to the -M:cider/nrepl
alias -> -M:cider/nrepl:dev:test
. I can then open the .clj
file I want, C-u C-z
to change to and load that namespace, and off to the races.
Now to put that in a .dir-locals.el
so I don't have to remember it each time. 🙂
Found it.
((clojure-mode . ((cider-clojure-cli-aliases . "-M:dev:test"))))