store/[org.clojure/clojure "1.8.0"] clj::clojure.core/test

Official Documentation

Add notes
Arities
==================================================
   [v]

Docstring
==================================================
  test [v] finds fn at key :test in var metadata and calls it,
  presuming failure will throw exception

Source

(defn test
  "test [v] finds fn at key :test in var metadata and calls it,
  presuming failure will throw exception"
  {:added "1.0"}
  [v]
    (let [f (:test (meta v))]
      (if f
        (do (f) :ok)
        :no-test)))

Example 1

Edit
(defn my-function
  "this function adds two numbers"
  {:test #(do
            (assert (= (my-function 2 3) 5))
            (assert (= (my-function 4 4) 8)))}
  ([x y] (+ x y)))

;; equal to (test (var my-function))
(test #'my-function)  
;; => :ok

-----------------------------------------------------------------------

(defn my-function
  "this function adds two numbers"
  {:test #(do
            (assert (= (my-function 2 3) 5))
            (assert (= (my-function 99 4) 8)))}
  ([x y] (+ x y)))

(test #'my-function)
;; => java.lang.AssertionError: Assert failed: (= (my-function 99 4) 8) (NO_SOURCE_FILE:0

---------------------------------------------------------------------------

(defn my-function
  "this function adds two numbers"
  ([x y] (+ x y)))

(test #'my-function)
;; => :no-test

Uses on crossclj