diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2009-12-01 11:02:54 -0500 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-12-08 07:42:53 -0500 |
commit | 607389029cfec50f32b73c00a6f66d0a1dbcda23 (patch) | |
tree | 4af0651a1b350bcb8bf884e07ac4245a9a634fb9 | |
parent | 151ca19ce958ecf736e8c863f58d68777de3dbe2 (diff) |
clojure.test/run-tests: return summary, add successful?; refs #193
Reformatted patch.
Signed-off-by: Rich Hickey <richhickey@gmail.com>
-rw-r--r-- | src/clj/clojure/test.clj | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/clj/clojure/test.clj b/src/clj/clojure/test.clj index 60a887eb..b341fcc0 100644 --- a/src/clj/clojure/test.clj +++ b/src/clj/clojure/test.clj @@ -683,11 +683,14 @@ (defn run-tests "Runs all tests in the given namespaces; prints results. - Defaults to current namespace if none given." + Defaults to current namespace if none given. Returns a map + summarizing test results." ([] (run-tests *ns*)) ([& namespaces] - (report (assoc (apply merge-with + (map test-ns namespaces)) - :type :summary)))) + (let [summary (assoc (apply merge-with + (map test-ns namespaces)) + :type :summary)] + (report summary) + summary))) (defn run-all-tests "Runs all tests in all namespaces; prints results. @@ -696,3 +699,10 @@ tested." ([] (apply run-tests (all-ns))) ([re] (apply run-tests (filter #(re-matches re (name (ns-name %))) (all-ns))))) + +(defn successful? + "Returns true if the given test summary indicates all tests + were successful, false otherwise." + [summary] + (and (zero? (:fail summary)) + (zero? (:error summary)))) |