Fork me on GitHub
#kaocha
<
2021-09-16
>
imre13:09:49

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 Brooks17:09:20

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

imre19:09:18

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 Brooks21:09:38

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

plexus05:09:40

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

imre16:09:27

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

imre18:09:45

Thanks @UE21H2HHD ! 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.

👍 2