Closed AlexChalk closed 2 months ago
Kaocha is "compatible" with expectations because expectations is compatible with clojure.test. It seems in this case they deviate from the clojure.test behavior.
I would try running with the debug
reporter and comparing the output.
I think it might actually be an easy fix, try adding this to report.clj
(see lines 276-280)
(defmethod print-expr 'not= [m]
(print-expression m))
Thanks for the quick reply. I've taken a look at report.clj
and done some println
debugging:
Expectations diverges from clojure-test here:
The if passes for clojure-test but not for expectations, which fails to satisfy (seq? (second (:actual m)))
.
(not (=....
, so (=...
satisfies seq?
.(not= val
, which doesn't. As a solution, what do you think about adding a new multimethod like this?
(defmulti get-actual
(fn [m] (first (:actual m))))
;; e.g. (not= ...)
(defmethod get-actual 'not= [m]
(-> m :actual))
;; e.g. (not (= ...))
(defmethod get-actual :default [m]
(-> m :actual second))
(defn print-expression [m]
(let [printer (output/printer)]
(if (and (not= (:type m) ::one-arg-eql)
(seq? (get-actual m))
(> (count (get-actual m)) 2))
(let [[_ expected & actuals] (get-actual m)]
(output/print-doc
I'd be happy to contribute this PR—I'll have some time next week. If that sounds good, can you point me to any development docs you have?
Go for it!
This was pretty short so I just submitted the PR. Tests pass locally, but it's failing one that seems unrelated in CI.
Any advice on the failing workflow?
I'm getting the
style output when I use kaocha with https://github.com/clojure-expectations/expectations.
Versions:
With regular clojure.test assertions:
Test file:
Output:
With clojure-expectations:
Test file:
Output:
I'm opening an issue as the docs suggest clojure-expectations is supported: https://cljdoc.org/d/lambdaisland/kaocha/1.0.861/doc/1-introduction#1-introduction.
Let me know if there's anything I can do to help debug. Thanks!