testing

Testing tools, testing philosophy & methodology...
Aleh Atsman 2020-11-11T17:14:57.011100Z

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 Alves 2020-11-11T18:07:19.011200Z

Hey @aleh_atsman, 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 Atsman 2020-11-11T18:08:11.011600Z

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 Atsman 2020-11-11T18:08:50.011800Z

It solved my problem

Jivago Alves 2020-11-11T18:16:55.012Z

cool!