off-topic

Ben Sless 2025-10-30T06:52:59.147439Z

Not sure where the right place for such a discussion is, but is anyone using with-test or set-test? What are your thoughts on attaching test cases to functions, executing them and rendering them as part of doc(s)?

Ben Sless 2025-10-30T06:53:12.617479Z

Yes, this is Unison envy

p-himik 2025-10-30T06:58:20.211469Z

I'd say #clojure is still the most relevant place. Also, an old somewhat relevant discussion: https://clojurians.slack.com/archives/C03RZGPG3/p1650317272864349 I'm still using that approach.

Ben Sless 2025-10-30T07:01:40.583549Z

huh, I even liked your comment in the thread

Ben Sless 2025-10-30T07:02:23.781619Z

the library metazoa also does something similar. I think the gap here exists in integration with other tools (e.g. clerk/kindly, test runners, etc)

2025-10-30T11:13:41.163379Z

i added support for metadata defined tests on vars in #lazytest but find that i still define tests in general in test files.

seancorfield 2025-10-30T13:59:13.237969Z

Part of the problem is that most test frameworks do not look at source folders by default, so tests attached to functions are ignored by default.

Samuel Ludwig 2025-10-30T14:12:01.307239Z

what would be the config necessary for the core clojure.test and kaocha? (i actually don't know of any other testing frameworks beyond those and @nbtheduke's)

2025-10-30T14:12:54.653479Z

to make them search other directories? either change the default in the code or pass in the appropriate flag at the cli

Samuel Ludwig 2025-10-30T14:17:00.139759Z

(looking now, might be a little more complicated if the test-runner is looking for a filename/ns pattern, it looks like kaocha looks at ns-patterns like "-test")

seancorfield 2025-10-30T14:33:23.898599Z

s/clojure.test/Cognitect's test-runner/ 🙂 You can specify directories to search for namespaces that contain tests. The default is "test" but you can add "src".

❤️ 1
seancorfield 2025-10-30T14:33:57.629619Z

And, yes, you may need to override the default pattern match on files/nses -- depends on the test runner.

seancorfield 2025-10-30T14:35:14.069889Z

I wrote about this in the Expectations docs https://cljdoc.org/d/com.github.seancorfield/expectations/2.2.214/doc/getting-started#test-placement

seancorfield 2025-10-30T14:35:59.587979Z

(I didn't cover Kaocha there, but it talks about lein test and the Cognitect test-runner)

phronmophobic 2025-10-30T17:32:23.096719Z

I think most code that uses a function doesn't actually care about loading/requiring the test for that function so there's some performance implications. > rendering them as part of doc(s)? I would make a distinction between tests and examples. I love the idea of making this data available to IDEs, but it should probably be optional.

Samuel Ludwig 2025-10-30T17:38:14.071949Z

I did play with Unison forever ago, and there definitely is something to having a function co-located with its tests, which is just very nice and self-contained/complete. I also do think that significance is much greater in non-REPLy/non-dynamic languages

➕ 1