Fork me on GitHub
#cider
<
2023-10-14
>
aisamu12:10:28

I wouldn't mind having this baked-in! Also made me think that I should probably try to make and bind a re-eval-deftest+re-test (Thanks, @timothypratley) https://x.com/timothypratley/status/1713043658403156225?s=20

simple_smile 1
vemv14:10:28

Defining/running a retriable form sounds suspiciously similar to defining/running a deftest :) So https://clojurians.slack.com/archives/C0617A8PQ/p1695734047060379 would be relevant OTOH I'd understand if it's excessively formal to some.

aisamu16:10:44

> Defining/running a retriable form sounds suspiciously similar to defining/running a deftest :) > Yes! But I would miss the nice test report!

vemv18:10:39

For that reason I'd favor deftests instead of ad-hoc repling :) (while of course I respect alternative workflows) One aspect that where CIDER (or clj-refactor) could be improved is that they make super easy to create a deftest. e.g. with a single keybinding have a file + ns form + stubbed deftest, ready to be run.

hifumi12309:10:56

When using lsp-mode, setting up the ns is halfway done for you as soon as you create a file. But I agree this can be automated a lot. We would have to be careful with ClojureScript, however, since there are differences in namespace and functionality of language itself. e.g. in JVM Clojure, I think this is idiomatic

(ns some.example-test
  (:require [clojure.test :refer :all]
            [some.example :as example]))

(deftest ...)
However, ClojureScript uses cljs.test and does not implement :refer :all. So the idiomatic way to scaffold the test namespace is like so.
(ns some.example-test
  (:require [cljs.test :refer [deftest testing is]]
            [some.example :as example]))

(deftest ...)
but we also have to be careful in what we refer, since many people use clojure-lsp, which will warn of unused bindings. Similarly, clj-kondo warns of any usage of :refer :all, even though its one (and only!) intended use case, according to the person who implemented it, is to pull in all public symbols of clojure.test.

vemv10:10:30

clj-refactor.el also does something very similar, including clj/s differences. One can customize the ns snippets as well. But it only happens when you create a new test file - that one step (plus the deftest insertion) is what I'd like to automate as a single action.