Closed Wegi closed 1 year ago
Can you try
[lambdaisland/kaocha "1.76.1230"]
{lambdaisland/kaocha {:mvn/version "1.76.1230"}}
please? I believe we merged a fix for this recently.
Worked, flawlessly. Thanks for the work. 👍
We've come across an issue related to this: If you run the test in a fixture twice and only the first instance fails, then the fail is printed but the returned result says that there are no failures.
Given:
(def ^:dynamic *val* 0)
(defn doubled-fixture [f]
(binding [*val* 1]
(f))
(binding [*val* 2]
(f)))
(use-fixtures :once doubled-fixture)
(deftest example-fail-test
(is (= *val* 2)))
Output:
$ clojure -M:test
[(F.)]
FAIL in noahtheduke.example.repo-test/example-fail-test (repo_test.clj:16)
Expected:
1
Actual:
-1 +2
1 tests, 1 assertions, 0 failures.
$ echo $?
0
Description:
When tests use fixtures like the following:
Then kaocha tries to cast the result of the
clean-db
call and not the test. E.g. if it is a Boolean, you get the exception:class java.lang.Boolean cannot be cast to class clojure.lang.Associative (java.lang.Boolean is in module java.base of loader 'bootstrap'; clojure.lang.Associative is in unnamed module of loader 'app')
The fixture pattern above is the usual fixture pattern and even used in multiple examples in the official documentation.
A temporary fix is to return the test result from the fixture, like so:
I can provide more example data, but this should be easy to reproduce.
Thanks!