Be compatible with Humane Test Output
Closed this issue · 3 comments
It would be ideal if activating Paul Stadig's HTO library enabled the improved reporting for equality. It overrides the assert-expr multimethod for = -- and of course that doesn't get invoked here.
If =? added the :diffs key, HTO could leverage that.
https://github.com/pjstadig/humane-test-output/blob/master/src/pjstadig/humane_test_output.clj#L16
There's a little bit more to it -- HTO changes how expected/actual are reported as well so you can't be both compatible with clojure.test and HTO at the same time, it has to be conditional.
Here's the diff that produces HTO-compatible output:
diff --git a/src/expectations/clojure/test.clj b/src/expectations/clojure/test.clj
index 2b02372..bc7189c 100755
--- a/src/expectations/clojure/test.clj
+++ b/src/expectations/clojure/test.clj
@@ -8,7 +8,8 @@
to clojure.test functionality.
We do not support ClojureScript in clojure.test mode, sorry."
- (:require [clojure.string :as str]
+ (:require [clojure.data :as data]
+ [clojure.string :as str]
[clojure.test :as t]))
;; stub functions for :refer compatibility:
@@ -37,9 +38,9 @@
(list '~e a#)
a#)})
(t/do-report {:type :fail, :message ~msg,
- :expected '~form, :actual (if (fn? e#)
- (list '~'not (list '~e a#))
- a#)}))
+ :diffs (if (fn? e#) [] [[a# (take 2 (data/diff e# a#))]])
+ :expected (if (fn? e#) '~form e#)
+ :actual (if (fn? e#) (list '~'not (list '~e a#)) [a#])}))
r#)))
(defmacro ?
I think we need to be conditional on HTO being in the mix as well.
The current expected/actual in e.c.t is not correct anyway:
FAIL in () (NO_SOURCE_FILE:1)
expected: (= (foo) (bar))
actual: (not (= {:a 1} {:b 2}))
false
user=> (expect (foo) (bar))
FAIL in () (NO_SOURCE_FILE:1)
expected: (=? (foo) (bar))
actual: {:b 2}
falseFixed via fa31fb6