Back
test-var (clj)
(source)function
(test-var v)
If v has a function in its :test metadata, calls that function,
with *testing-vars* bound to (conj *testing-vars* v).
Examples
clojure
(ns clojure.test-clojure.run-single-test
(:require [clojure.test :refer [is deftest run-test run-tests]]
[clojure.test-helper :refer [with-err-string-writer]]
[clojure.test-clojure.test-fixtures :as tf]))
(deftest reports-non-test-var
(should-print-to-err #"^.*/not-a-test is not a test.*"
(let [result (eval `(run-test not-a-test))]
(is (nil? result)))))
tonsky/datascript
(ns datascript.test.ident
(:require
[clojure.test :as t :refer [is are deftest testing]]
[datascript.core :as d]))
#_(user/test-var #'test-transact!)
#_(t/test-ns 'datascript.test.ident)
babashka/babashka
(ns foo
(:require
[clojure.test :as t]))
(binding [t/report (fn [m]
(prn (update m :var (comp :name meta))))]
(t/test-var #'bar))
replikativ/datahike
(ns datahike.test.ident-test
(:require
[clojure.test :as t :refer [is deftest]]
[datahike.api :as d]
[datahike.db :as db]))
#_(user/test-var #'test-transact!)
#_(t/test-ns 'datahike.test.ident)
juji-io/datalevin
(ns datalevin.test.query-pull
(:require
[datalevin.test.core :as tdc :refer [db-fixture]]
[clojure.test :refer [deftest testing are is use-fixtures]]
[datalevin.core :as d]
[datalevin.util :as u])
(:import [java.util UUID]))
(deftest test-var-pattern
(let [dir (u/tmp-dir (str "pull-test-" (UUID/randomUUID)))
test-db (d/db-with (d/empty-db dir)
[{:db/id 1 :name "Petr" :age 44}
{:db/id 2 :name "Ivan" :age 25}
{:db/id 3 :name "Oleg" :age 11}])]
(are [find pattern res] (= (set (d/q {:find find
:in '[$ ?pattern]
:where '[[?e :age ?a]
[(>= ?a 18)]]}
test-db pattern))
res)
'[(pull ?e ?pattern)] [:name]
#{[{:name "Ivan"}] [{:name "Petr"}]}
clj-commons/etaoin
(ns etaoin.test-report
(:require [clojure.test]))
(defmethod clojure.test/report :begin-test-var [m]
(let [test-name (-> m :var meta :name)]
(if (bound? #'*context*)
(println (format "=== %s [%s][%s]" test-name platform *context*))
(println (format "=== %s [%s]" test-name platform)))))