Use indented output.
This commit is contained in:
parent
c017760acf
commit
8ad500acf4
3 changed files with 45 additions and 50 deletions
38
README.org
38
README.org
|
@ -19,37 +19,31 @@
|
|||
You get this:
|
||||
: FAIL in (a-test) (humane_test_output_test.clj:7)
|
||||
: FIXME, I fail.
|
||||
: expected:
|
||||
: {:another-key "and another value",
|
||||
: expected: {:another-key "and another value",
|
||||
: :foo :bar,
|
||||
: :something "a long string?",
|
||||
: :baz :quux}
|
||||
:
|
||||
: actual:
|
||||
: {:another-key "and another value",
|
||||
: actual: {:fo :bar}
|
||||
: diff: {:baz :quux,
|
||||
: :something "a long string?",
|
||||
: :fo :bar,
|
||||
: :baz :quux}
|
||||
:
|
||||
: diff:
|
||||
: {:foo :bar}
|
||||
: :foo :bar,
|
||||
: :another-key "and another value"}
|
||||
: {:fo :bar}
|
||||
:
|
||||
: FAIL in (a-test) (humane_test_output_test.clj:11)
|
||||
: FAIL in (a-test) (humane_test_output_test.clj:10)
|
||||
: FIXME, I fail.
|
||||
: expected:
|
||||
: {:foo :bar, :baz :quux}
|
||||
: expected: {:foo :bar, :baz :quux}
|
||||
: actual: {:fo :bar, :baz :quux}
|
||||
: diff: {:foo :bar}
|
||||
: {:fo :bar}
|
||||
: actual: {:foo :bar, :baz :quux}
|
||||
: diff: nil
|
||||
: nil
|
||||
:
|
||||
: actual:
|
||||
: ({:foo :bar, :baz :quux} {:fo :bar, :baz :quux})
|
||||
:
|
||||
: FAIL in (a-test) (humane_test_output_test.clj:14)
|
||||
: FAIL in (a-test) (humane_test_output_test.clj:13)
|
||||
: FIXME, I fail.
|
||||
: expected:
|
||||
: (list? foo)
|
||||
:
|
||||
: actual:
|
||||
: (not
|
||||
: expected: (list? foo)
|
||||
: actual: (not
|
||||
: (list?
|
||||
: {:another-key "and another value",
|
||||
: :foo :bar,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns pjstadig.humane-test-output
|
||||
(:use [clojure.data]
|
||||
[clojure.pprint :only [get-pretty-writer pprint pprint-indent pprint-logical-block write]]
|
||||
[clojure.pprint :only [get-pretty-writer pprint]]
|
||||
[clojure.test]))
|
||||
|
||||
(defmethod assert-expr '= [msg [_ a & more]]
|
||||
|
@ -10,26 +10,28 @@
|
|||
(if result#
|
||||
(do-report {:type :pass, :message ~msg,
|
||||
:expected a#, :actual more#})
|
||||
(do-report (merge {:type :fail, :message ~msg,
|
||||
:expected a#, :actual more#}
|
||||
(if (= (count more#) 1)
|
||||
{:actual (first more#)
|
||||
:diff (take 2 (diff a# (first more#)))}
|
||||
{:actual more#}))))
|
||||
(do-report {:type :fail, :message ~msg,
|
||||
:expected a#, :actual more#,
|
||||
:diffs (zipmap more# (map #(take 2 (diff a# %)) more#))}))
|
||||
result#))
|
||||
|
||||
(defmethod clojure.test/report :fail
|
||||
[{:keys [type expected actual diff message] :as event}]
|
||||
[{:keys [type expected actual diffs message] :as event}]
|
||||
(with-test-out
|
||||
(inc-report-counter :fail)
|
||||
(println "\nFAIL in" (testing-vars-str event))
|
||||
(when (seq *testing-contexts*) (println (testing-contexts-str)))
|
||||
(when message (println message))
|
||||
(println "expected:")
|
||||
(binding [*out* (get-pretty-writer *out*)]
|
||||
(print "expected: ")
|
||||
(pprint expected)
|
||||
(println "\nactual:")
|
||||
(if (seq diffs)
|
||||
(doseq [[actual [a b]] diffs]
|
||||
(print " actual: ")
|
||||
(pprint actual)
|
||||
(when-let [[a b] diff]
|
||||
(println "\ndiff:")
|
||||
(print " diff: ")
|
||||
(pprint a)
|
||||
(pprint b))))
|
||||
(print " ")
|
||||
(pprint b))
|
||||
(do (print " actual: ")
|
||||
(pprint actual))))))
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
(testing "FIXME, I fail."
|
||||
(is (= {:foo :bar :baz :quux :something "a long string?"
|
||||
:another-key "and another value"}
|
||||
{:fo :bar :baz :quux :something "a long string?"
|
||||
:another-key "and another value"}))
|
||||
{:fo :bar}))
|
||||
(is (= {:foo :bar :baz :quux} {:foo :bar :baz :quux} {:fo :bar :baz :quux}))
|
||||
(let [foo {:foo :bar :baz :quux :something "a long string?"
|
||||
:another-key "and another value"}]
|
||||
|
|
Loading…
Reference in a new issue