|
69 | 69 | (println "not ok" msg)) |
70 | 70 |
|
71 | 71 | ;; This multimethod will override test/report |
72 | | -(defmulti ^:dynamic tap-report (fn [data] (:type data))) |
| 72 | +(defmulti ^:dynamic tap-report :type) |
73 | 73 |
|
74 | 74 | (defmethod tap-report :default [data] |
75 | 75 | (t/with-test-out |
76 | 76 | (print-tap-diagnostic (pr-str data)))) |
77 | 77 |
|
| 78 | +(defn print-diagnostics [data] |
| 79 | + (when (seq t/*testing-contexts*) |
| 80 | + (print-tap-diagnostic (t/testing-contexts-str))) |
| 81 | + (when (:message data) |
| 82 | + (print-tap-diagnostic (:message data))) |
| 83 | + (print-tap-diagnostic (str "expected:" (pr-str (:expected data)))) |
| 84 | + (if (= :pass (:type data)) |
| 85 | + (print-tap-diagnostic (str " actual:" (pr-str (:actual data)))) |
| 86 | + (do |
| 87 | + (print-tap-diagnostic |
| 88 | + (str " actual:" |
| 89 | + (with-out-str |
| 90 | + (if (instance? Throwable (:actual data)) |
| 91 | + (stack/print-cause-trace (:actual data) t/*stack-trace-depth*) |
| 92 | + (prn (:actual data))))))))) |
| 93 | + |
78 | 94 | (defmethod tap-report :pass [data] |
79 | 95 | (t/with-test-out |
80 | 96 | (t/inc-report-counter :pass) |
81 | 97 | (print-tap-pass (t/testing-vars-str data)) |
82 | | - (when (seq t/*testing-contexts*) |
83 | | - (print-tap-diagnostic (t/testing-contexts-str))) |
84 | | - (when (:message data) |
85 | | - (print-tap-diagnostic (:message data))) |
86 | | - (print-tap-diagnostic (str "expected:" (pr-str (:expected data)))) |
87 | | - (print-tap-diagnostic (str " actual:" (pr-str (:actual data)))))) |
| 98 | + (print-diagnostics data))) |
88 | 99 |
|
89 | 100 | (defmethod tap-report :error [data] |
90 | 101 | (t/with-test-out |
91 | 102 | (t/inc-report-counter :error) |
92 | 103 | (print-tap-fail (t/testing-vars-str data)) |
93 | | - (when (seq t/*testing-contexts*) |
94 | | - (print-tap-diagnostic (t/testing-contexts-str))) |
95 | | - (when (:message data) |
96 | | - (print-tap-diagnostic (:message data))) |
97 | | - (print-tap-diagnostic (str "expected:" (pr-str (:expected data)))) |
98 | | - (print-tap-diagnostic " actual: ") |
99 | | - (print-tap-diagnostic |
100 | | - (with-out-str |
101 | | - (if (instance? Throwable (:actual data)) |
102 | | - (stack/print-cause-trace (:actual data) t/*stack-trace-depth*) |
103 | | - (prn (:actual data))))))) |
| 104 | + (print-diagnostics data))) |
| 105 | + |
| 106 | +(defmethod tap-report :fail [data] |
| 107 | + (t/with-test-out |
| 108 | + (t/inc-report-counter :fail) |
| 109 | + (print-tap-fail (t/testing-vars-str data)) |
| 110 | + (print-diagnostics data))) |
104 | 111 |
|
105 | 112 | (defmethod tap-report :summary [data] |
106 | 113 | (t/with-test-out |
|
0 commit comments