From be2e0658fc8c76053320ae8952eab0bababe635f Mon Sep 17 00:00:00 2001 From: nmburgan <13688219+nmburgan@users.noreply.github.com> Date: Fri, 16 Jan 2026 12:37:27 -0800 Subject: [PATCH] Add test summary for the end of lein test The test suite generates quite a lot of errors that are actually expected and not test failures, so it's hard to pick out what the real failures were. This adds a wrapper that collects all of the real failures and prints them out at the end of the test run. --- project.clj | 1 + test/test_summary.clj | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/test_summary.clj diff --git a/project.clj b/project.clj index 01165c8f6..b9ddab3f7 100644 --- a/project.clj +++ b/project.clj @@ -305,6 +305,7 @@ :dev-settings {:dependencies [[org.bouncycastle/bcpkix-jdk18on]] :plugins [[jonase/eastwood "1.4.3"]] + :injections [(require 'test-summary)] :jvm-opts ~(conj pdb-jvm-opts "-XX:-OmitStackTraceInFastThrow")} :dev [:defaults :dev-settings] diff --git a/test/test_summary.clj b/test/test_summary.clj new file mode 100644 index 000000000..157e5e1b8 --- /dev/null +++ b/test/test_summary.clj @@ -0,0 +1,38 @@ +(ns test-summary + (:require [clojure.test :as t])) + +(def ^:private failures (atom [])) + +(defonce ^:private original-report-fail (get-method t/report :fail)) +(defonce ^:private original-report-error (get-method t/report :error)) +(defonce ^:private original-report-summary (get-method t/report :summary)) + +(defmethod t/report :fail [m] + (swap! failures conj (assoc m + :test-var (first t/*testing-vars*) + :contexts t/*testing-contexts*)) + (original-report-fail m)) + +(defmethod t/report :error [m] + (swap! failures conj (assoc m + :test-var (first t/*testing-vars*) + :contexts t/*testing-contexts*)) + (original-report-error m)) + +(defmethod t/report :summary [m] + (original-report-summary m) + (when (seq @failures) + (println "\n\n========== FAILURE SUMMARY ==========\n") + (doseq [{:keys [type test-var message expected actual file line]} @failures] + (println (str (name type) ": " + (when test-var + (str (-> test-var meta :ns) "/" (-> test-var meta :name))))) + (when (and file line) + (println (str " at " file ":" line))) + (when message + (println (str " " message))) + (println (str " expected: " (pr-str expected))) + (println (str " actual: " (pr-str actual))) + (println)) + (println "======================================\n")) + (reset! failures []))