Cursive connected to a remote lein repl
process (nREPL, no socket REPL support yet) since I want that process to run longer than Cursive.
My CLJ workflow involves deftest
and Cursive Run <test> in REPL
. I have that plus Re-Run last test action in REPL
bound to keys so I can easily “select” a test and run it on demand wherever I am in the source. No need to fiddle with the REPL window at all.
These are not tests in the traditional sense though. They often don’t even contain any assertions and may just print their results (like the REPL would). The “test” trick is just for convenience so that I don’t have to jump around my editor so much. Just hit the keybinding for “re-run” when making a change is nice. Depending on how much state the “test” needs I either re-create everything from scratch when executing or use a defonce
atom
somewhere.
I don’t usually maintain these “tests” either. They are isolated to their own source path and are for exploration only. Just a bunch of (deftest thing-im-thinking-about ...)
in one large file or spread across many depending on the general “topic”. After a while these things typically break or don’t even make sense anymore. Sometimes they get deleted, sometimes they just stay as a reminder. Either is fine.
Basically these “tests” just serve as re-usable self-contained snippets that I can modify and invoke easily but don’t have to worry about “maintaining”. Sometimes actual tests are made out of these later though, which can also be used by CI. Just need to add the assertions basically.
I very rarely type into the REPL itself. I sometimes have (comment ...)
blocks which contain a few instructions which I “Send X to REPL” but these would also be in the “test files”. I do have some other key-bindings which just send common things to the REPL like (repl/stop)
(repl/start)
or the combined (repl/go)
which would start my dev setup. I could type these I guess but I’m lazy.
I would use this workflow for CLJS as is but unfortunately Cursive doesn’t let me (yet). Kinda got used to just abusing live-reload so I barely ever use the REPL at all for CLJS.
You can look at examples for this workflow in the shadow-cljs
repo (everything in src/repl
are these exploratory tests) and the repl
util namespace.