kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
2020-06-12T04:42:22.317500Z

This was similar to the idea of using codeq to check which function change and run the test calling the function. Especially for pure functions it makes sense.

2020-06-12T04:43:45.318Z

But yeah it would be great!

plexus 2020-06-12T05:55:19.318700Z

@aviflax I think you hit a pretty specific edge case, I wouldn't worry about it too much

plexus 2020-06-12T06:00:29.322Z

Clojure is to some extent statically analyzable, that's what e.g. Cursive does, because functions generally are not polymorphic. In Ruby every method call is polymorphic, you never know what implementation gets called unless you know the runtime type. Clojure does have polymorphism as well though, through multimethods, protocols, interfaces, proxy/reify, so you have the same problem there. Plus we have macros. So in practice you only get so far with static analysis.

plexus 2020-06-12T06:04:03.324Z

There's an alternative approach where you adopt conventions to make it clear which tests test a certain function, this is what Mutant does (https://github.com/mbj/mutant/blob/master/docs/mutant-rspec.md#test-selection). When you are doing mutation testing you need to be able to narrow down the number of tests to run, otherwise it becomes impossibly slow, so Mutant expects that you name your tests in such a way that it can determine which class/method is being tested. In Clojure we could use metadata for this.

plexus 2020-06-12T06:04:46.324900Z

(deftest ^{:test/subject #'my.example/some-fn} some-fn-test ,,,)

plexus 2020-06-12T06:06:39.326200Z

this is of course more limited than the call graph approach, in this case you won't get the tests that indirectly call some-fn. When you're doing mutation testing that's good though, because it forces you to test all functionality explicitly.

rgm 2020-06-12T19:35:45.327100Z

oh, interesting. Hadn’t really looked that hard into mutation testing.

rgm 2020-06-12T19:36:27.327900Z

(I also don’t have enough tests anywhere to really warrant that call graph business, though it might be interesting for longer-running tests like a cucumber browser suite).