Fork me on GitHub
#testing
<
2021-03-30
>
Noah Bogart13:03:37

is it possible to exit a single test early? I want to be able to say (deftest sample (is-2 (= 1 2) "Stop here please") (is (= 1 2) "Never checked")) and have the second is not ran because it early exits but while still running all of the other deftest s

vemv17:03:53

as a cheap trick you could wrap each is in an assert Without a helper like that, you'd have to hack the clojure.test multimethods. https://github.com/circleci/circleci.test/ implements fail-fast (at deftest level; not at is level) so you can take some inspiration from there

Noah Bogart18:03:20

I can't find anything about fail-fast in circleci.test. have a line number for me to look at?

vemv18:03:14

slightly misremembered :) it's not implemented there, but I hacked locally and also reflected my technique here https://github.com/circleci/circleci.test/issues/39

👍 3
Noah Bogart18:03:56

oh i see, this is about aborting all future deftests if a given one fails. yeaeh that would be helpful but is different than i'm looking for. i'll pursue modifying/writing a wrapper for deftest. thank you!

plexus07:04:52

Kaocha implements fail-fast at the "is" level, we throw/catch a custom exception to break out of the current deftest.

Noah Bogart11:04:41

That’s cool! I’ll check out Kaocha