Fork me on GitHub
#testing
<
2022-10-26
>
plexus14:10:27

In clojure.test you can rebind the reporter to a regular function or a multimethod. If you rebind to a regular function you do have to make sure you do it after any code that assumes it's a multimethod. If you use kaocha you can supply multiple reporters, so you can have one that simply checks for (= (:type m) :fail) and does nothing for other events

alex21:10:15

Thanks for the tip! Unfortunately not using Kaocha, but having multiple reporters support out of the box sounds great. Might have to explore Kaocha more 🙂 Would you rebind the reporter via binding or something else?

plexus14:10:21

it's not a dynamic var, so you'd have to use with-redefs

1
Phillip Mates14:02:10

you can also do some hackery to re-define the clojure.test/report multimethod and still call to the original implementation as well capture the old impl: https://gist.github.com/philomates/32f8e1f7a2a4e746ac0186964aaaa2d3#file-flow-clj-L12 override the original, do custom logic, and then call the original to preserve existing behavior: https://gist.github.com/philomates/32f8e1f7a2a4e746ac0186964aaaa2d3#file-flow-clj-L32-L34