kaocha

imre 2021-09-16T13:53:49.041600Z

Is it okay in kaocha for a plugin to declare a test suite failed? And if yes, where in the documentation could I find how to do that?

Alys Brooks 2021-09-16T17:33:20.042600Z

Your plugin would probably be a separate library, so it's up to you. Or are you asking if marking it as failed would break something? I'm pretty sure you can use a post-test hook or use post-test or post-run in your plugin to change the status of individual tests. Here's an example of using a hook to modify individual testables: https://cljdoc.org/d/lambdaisland/kaocha/1.0.887/doc/10-hooks#pre-test--post-test

imre 2021-09-16T19:47:18.043200Z

I'm looking to write a plugin that would basically make the test run fail when there were no tests found/run in certain test suites. Thank you for the pointers. I was basically just trying to check whether this is ok or an anti-pattern

Alys Brooks 2021-09-16T21:07:38.043400Z

I can't think of any major issues with doing that, although I'd be interested in @plexus' thoughts.

plexus 2021-09-17T05:27:40.043600Z

yeah that is totally something a plugin should be able to do

imre 2021-09-20T16:54:27.044100Z

I ended up doing this with a kaocha.output/error-and-throw :kaocha/early-exit in the post-load hook in the end, thank you for the help

lread 2021-09-20T18:06:16.046900Z

@imre I’m a bit late to respond, but did this for https://github.com/lread/test-doc-blocks/blob/de783e9d467a7b4363271504a6fb2c6562167b06/tests.edn#L12

imre 2021-09-20T18:25:45.047100Z

Thanks @lee ! I actually considered hooks at some point but ended up going with a plugin as I wanted the team to be able to just reference the plugin and get some default config out of the box (namely, which suited should be checked by default). The plugin is in a lib where we keep our build/test-time utilities.

šŸ‘ 1