is there a way to only fail fast for each deftest
context? i.e. adapting this example https://cljdoc.org/d/lambdaisland/kaocha/0.0-359/doc/-fail-fast-option
Given a file named "test/my/project/fail_fast_test.clj" with:
(ns my.project.fail-fast-test
(:require [clojure.test :refer :all]))
(deftest test-1
(is true))
(deftest test-2
(is true)
(is false)
(is true))
(deftest test-3
(is true))
When I run bin/kaocha --fail-fast
Then the exit-code should be 1
And the output should contain:
[(..F.)]
FAIL in my.project.fail-fast-test/test-2 (fail_fast_test.clj:9)
expected: false
actual: false
3 tests, 4 assertions, 1 failures.
context is that for integration tests I don’t want to continue if a pre-condition has failed as the output becomes hard to follow
I guess the equivalent from another language would be testify/assert
vs testify/require
in the Go library https://github.com/stretchr/testify
easiest would be to just throw an exception
that's what fail-fast does too under the hood, it's only way to "break out" of a running deftest
ah, so I could in theory wrap is
with something else, such as is-required
and just throw out of it? That could work
something like that, or have your own variant of is
which throws on failure. is
by default catches all exceptions inside the is
yup, just checked out the implementation which hadn’t inspected before. Thanks for your help!
worked a charm :star-struck:
Hi all, I am trying to figure out how to specify a namespace exclusion with kaocha. Here's what is in my deps.edn:
:coverage {:extra-deps {lambdaisland/kaocha-cloverage {:mvn/version "RELEASE"}}
:main-opts ["-m" "kaocha.runner"
"--plugin" "cloverage"
"--ns-exclude-regex" "app.main"]}
The --ns-exclude regex should be a vector of regexes. I am not quite sure how to do this with deps. Do I do a literal list in the string?start with bin/kaocha --help
, you will see that there is no --ns-exclude-regex
option, but there is a --cov-ns-exclude-regex
just pass it a string as you do now, if you want to pass more than one then specify the option more than once
thanks!