Back
testing-vars-str (clj)
(source)function
(testing-vars-str m)
Returns a string representation of the current test. Renders names
in *testing-vars* as a list, then the source file and line of
current assertion.
Examples
clojure/core.typed
(ns clojure.core.typed.test.testnew
(:require [clojure.core.typed :as t]
[clojure.test :refer :all]
[clojure.core.typed.test.test-utils :refer :all]
[clojure.core.typed.test.destructure]))
(deftest function?-test
(is-tc-e (function? function?) Boolean
:requires [[clojure.test :refer [function?]]])
(is-tc-err (function? function?) String
:requires [[clojure.test :refer [function?]]]))
(deftest assert-any-test
(is-tc-e (assert-any "Hi" (= 4 (+ 2 2))) Any
:requires [[clojure.test :refer [assert-any]]]))
(deftest do-report-test
(is-tc-e #(do-report 1)
:requires [[clojure.test :refer [do-report]]]))
(deftest run-tests-test
(is-tc-e #(run-tests) [-> (Map Any Any)]
:requires [[clojure.test :refer [run-tests]]])
(is-tc-err #(run-tests) [-> String]
:requires [[clojure.test :refer [run-tests]]]))
(deftest run-all-tests-test
(is-tc-e #(run-all-tests) [-> (Map Any Any)]
:requires [[clojure.test :refer [run-all-tests]]])
(is-tc-e #(run-all-tests #"asdf") [-> (Map Any Any)]
:requires [[clojure.test :refer [run-all-tests]]])
(is-tc-err #(run-all-tests) [:-> String]
:requires [[clojure.test :refer [run-all-tests]]]))
(deftest successful?-test
(is-tc-e #(successful? {}) [-> Boolean]
:requires [[clojure.test :refer [successful?]]]))
(deftest compose-fixtures-test
(is-tc-e (compose-fixtures (fn [a :- [-> Any]] (a))
(fn [b :- [-> Any]] (b)))
[[-> Any] -> Any]
:requires [[clojure.test :refer [compose-fixtures]]]))
(deftest testing-vars-str-test
(is-tc-e #(testing-vars-str {}) [-> String]
:requires [[clojure.test :refer [testing-vars-str]]])
(is-tc-err (testing-vars-str 1) Int
:requires [[clojure.test :refer [testing-vars-str]]]))
(deftest testing-contexts-str-test
(is-tc-e (testing-contexts-str) String
:requires [[clojure.test :refer [testing-contexts-str]]])
(is-tc-err (testing-contexts-str) (Map Any Any)
:requires [[clojure.test :refer [testing-contexts-str]]])
(is-tc-err (testing-contexts-str 1) String
:requires [[clojure.test :refer [testing-contexts-str]]]))
lambdaisland/kaocha
(ns kaocha.report-test
(:require [clojure.test :as t :refer :all]
[kaocha.report :as report]
[kaocha.type :as type]
[kaocha.test-util :refer [with-test-out-str]]
[kaocha.output :as output]
[kaocha.hierarchy :as hierarchy]
[kaocha.history :as history]
[kaocha.testable :as testable]
[slingshot.slingshot :refer [try+]]))
(deftest testing-vars-str-test
(testing "getting info from testable"
(is (= "foo/bar (foo.clj:33)"
(report/testing-vars-str {:kaocha/testable
{:kaocha.testable/meta
{:file "foo.clj"
:line 33}
:kaocha.testable/id :foo/bar}}))))
(testing "explicit file/line override"
(is (= "foo/bar (foo.clj:33)"
(report/testing-vars-str {:file "foo.clj"
:line 33
:kaocha/testable {:kaocha.testable/id :foo/bar
:file "bar.clj"
:line 44}}))))
(testing "clojure.test legacy compatiblity"
(is (= "(report-counters-test) (foo.clj:33)"
(report/testing-vars-str {:file "foo.clj"
:line 33
:testing-vars [#'report-counters-test]})))))
typedclojure/typedclojure
(ns clojure.core.typed.test.testnew
(:require [typed.clojure :as t]
[clojure.test :refer :all]
[typed.clj.checker.test-utils :refer :all]))
(deftest function?-test
(is-tc-e (function? function?) t/Bool
:requires [[clojure.test :refer [function?]]])
(is-tc-err (function? function?) t/Str
:requires [[clojure.test :refer [function?]]]))
(deftest assert-any-test
(is-tc-e (assert-any "Hi" (= 4 (+ 2 2))) t/Any
:requires [[clojure.test :refer [assert-any]]]))
(deftest do-report-test
(is-tc-e #(do-report 1)
:requires [[clojure.test :refer [do-report]]]))
(deftest run-tests-test
(is-tc-e #(run-tests) [-> (t/Map t/Any t/Any)]
:requires [[clojure.test :refer [run-tests]]])
(is-tc-err #(run-tests) [-> t/Str]
:requires [[clojure.test :refer [run-tests]]]))
(deftest run-all-tests-test
(is-tc-e #(run-all-tests) [-> (t/Map t/Any t/Any)]
:requires [[clojure.test :refer [run-all-tests]]])
(is-tc-e #(run-all-tests #"asdf") [-> (t/Map t/Any t/Any)]
:requires [[clojure.test :refer [run-all-tests]]])
(is-tc-err #(run-all-tests) [:-> t/Str]
:requires [[clojure.test :refer [run-all-tests]]]))
(deftest successful?-test
(is-tc-e #(successful? {}) [-> t/Bool]
:requires [[clojure.test :refer [successful?]]]))
(deftest compose-fixtures-test
(is-tc-e (compose-fixtures (fn [a :- [-> t/Any]] (a))
(fn [b :- [-> t/Any]] (b)))
[[-> t/Any] -> t/Any]
:requires [[clojure.test :refer [compose-fixtures]]]))
(deftest testing-vars-str-test
(is-tc-e #(testing-vars-str {}) [-> t/Str]
:requires [[clojure.test :refer [testing-vars-str]]])
(is-tc-err (testing-vars-str 1) t/Int
:requires [[clojure.test :refer [testing-vars-str]]]))
(deftest testing-contexts-str-test
(is-tc-e (testing-contexts-str) t/Str
:requires [[clojure.test :refer [testing-contexts-str]]])
(is-tc-err (testing-contexts-str) (t/Map t/Any t/Any)
:requires [[clojure.test :refer [testing-contexts-str]]])
(is-tc-err (testing-contexts-str 1) t/Str
:requires [[clojure.test :refer [testing-contexts-str]]]))
jakemcc/test-refresh
(ns lein2.sample-report
(:require [clojure.test :as t]))
(defmethod my-report :error [m]
(t/with-test-out
(t/inc-report-counter :error)
(println "\nERROR in" (t/testing-vars-str m))
(when-let [message (:message m)] (println message))
(println "expected:" (pr-str (:expected m)))
(println " actual:" (pr-str (:actual m)))
(println)))
(defmethod my-report :fail [m]
(t/with-test-out
(t/inc-report-counter :fail)
(println "\nFAIL in" (t/testing-vars-str m))
(when-let [message (:message m)] (println message))
(println "expected:" (pr-str (:expected m)))
(println " actual:" (pr-str (:actual m)))
(println)))
borkdude/speculative
(ns speculative.test-prelude
(:require [clojure.test :as t]))
#?(:cljs
(defmethod cljs.test/report [:cljs.test/default :begin-test-var] [m]
;; for debugging:
#_(println ":begin-test-var" (cljs.test/testing-vars-str m))))