liveBook · Manning

Run-tests

As explained in Clojure: The Essential Reference

run-tests is a clojure.test function that runs tests in one or more namespaces and prints a summary.

run-tests runs tests in one or more namespaces and prints a final summary. With no arguments, it runs the current namespace. section 22.9

Use run-tests when you want namespace-level test execution with summarized results:

  • Runs the current namespace when called without arguments. section 22.9
  • Reports test, assertion, pass, failure, and error counts in a summary map. section 22.9
  • Differs from test-ns by adding a summary at the end; run-all-tests handles all loaded namespaces and namespace filtering. section 22.9

Running the current namespace

(run-tests) ;; Testing running-tests ;; Ran 3 tests containing 3 assertions. ;; 0 failures, 0 errors. ;; {:test 3, :pass 3, :fail 0, :error 0, :type :summary} section 22.9

(ns running-tests)
(require '[clojure.test :refer [is deftest run-tests]])

(deftest a (is (= 4 (+ 2 2))))
(deftest b (is (= 4 (+ 2 2))))
(deftest c (is (= 4 (+ 2 2))))

(run-tests)
;; Testing running-tests
;;
;; Ran 3 tests containing 3 assertions.
;; 0 failures, 0 errors.
;; {:test 3, :pass 3, :fail 0, :error 0, :type :summary}

Inspect a complete namespace-level run and its printed summary. section 22.9

How Clojure: The Essential Reference covers it

How deep it goes
Defines default namespace selection and summary output, while deferring loaded-namespace filtering to run-all-tests.
Examples
Demonstrates three passing tests in the current namespace with zero failures and errors.
What it assumes
Assumes tests are declared in a namespace, typically with deftest.
What you can do after
Apply clojure.test to execute current-namespace tests and inspect aggregate pass, failure, and error counts.
How it connects
Connects test-ns, test-all-vars, run-all-tests, fixtures, and test-ns-hook.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.