Fork me on GitHub
#testing
<
2020-11-11
>
Aleh Atsman17:11:57

Hey! Does anyone know a way to expect standard diff function of clojure.test/is macro with lambdaisland.deep-diff2 in order to be able to do nice diffing and quickly see what is wrong?

Jivago Alves18:11:19

Hey @U4N27TADS, we use https://github.com/weavejester/eftest at our projects. It provides a decent pretty diff. I’m not sure but by looking at its code, it looks like eftest defines a custom https://github.com/weavejester/eftest/blob/master/eftest/src/eftest/runner.clj#L211 for clojure.test/report. I’d recommend taking a look at it.

Aleh Atsman18:11:11

Hey thx for reply, I played around and extended report function next way:

(defmethod report :fail [m]
  (with-test-out
    (inc-report-counter :fail)
    (println "\nFAIL in" (testing-vars-str m))
    (when (seq *testing-contexts*) (println (testing-contexts-str)))
    (when-let [message (:message m)] (println message))
    ;(println "expected:" (pr-str (:expected m)))
    ;(println "  actual:" (pr-str (:actual m)))
    (let [[expected actual] (as-> m m
                              (m :actual)
                              (nth m 1)
                              (vec m)
                              (drop 1 m))]
      (ddiff/pretty-print (ddiff/diff expected actual)))))

Aleh Atsman18:11:50

It solved my problem