Back
inc-report-counter (clj)
(source)function
(inc-report-counter name)
Increments the named counter in *report-counters*, a ref to a map.
Does nothing if *report-counters* is nil.
Examples
jakemcc/test-refresh
(ns lein2.sample-report
(:require [clojure.test :as t]))
(defmethod my-report :pass [m]
(t/with-test-out
(t/inc-report-counter :pass)))
(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)))
hyperfiddle/rcf
(ns hyperfiddle.rcf.reporters
(:require [clojure.test :as t]
[clojure.string :as str]))
(defmethod t/report :hyperfiddle.rcf/pass [_m]
(t/with-test-out
(t/inc-report-counter :pass)
(print "✅")
(flush)))
ccfontes/eg
(ns eg.report.clj ^{:author "Carlos da Cunha Fontes"
:license {:name "The MIT License"
:url "https://github.com/ccfontes/eg/blob/master/LICENSE.md"}}
(:require [clojure.string :as str]
[clojure.test :as clj.test]
[eg.platform]
[eg.report :refer [->testing-fn-repr
do-example-equal-report
do-example-pred-report
do-expression-equal-report
do-expression-pred-report
do-spec-report
do-expected-spec-report
do-expression-expected-spec-report
print-report
spec->because-error
spec-because]]))
(defmethod clj.test/report :fail-spec
; Source: https://github.com/clojure/clojure/blob/master/src/clj/clojure/test.clj
[{:keys [spec-kw example example-code spec-error-data expect-valid? file line]}]
(clj.test/with-test-out
(let [example-code? (or (not= example example-code) (not expect-valid?))]
(clj.test/inc-report-counter :fail)
(println "\nFAIL in spec" (list spec-kw) (list (str file ":" line)))
(if example-code? (println (str "in example:" (if-not expect-valid? " !")) (pr-str example-code)))
(println (spec-because example (some-> spec-error-data spec->because-error) expect-valid?)))))
(defmethod clj.test/report :fail-default
; Source: https://github.com/clojure/clojure/blob/master/src/clj/clojure/test.clj
[m] (clj.test/with-test-out
(clj.test/inc-report-counter :fail)
(print-report m)))