Back
*test-out* (clj)
(source)variable
Examples
lambdaisland/kaocha
(ns kaocha.test-util
(:require [clojure.test :as t]
[clojure.spec.alpha :as spec]
[expound.alpha :as expound]
[kaocha.report :as report]
[kaocha.testable :as testable]
[kaocha.output :as output]
[kaocha.type :as type]))
(defmacro with-test-out-str
"Evaluates exprs in a context in which [[clojure.test/*test-out*]] is bound to a
fresh StringWriter. Returns the string created by any nested printing calls
that use [[clojure.test/with-test-out]]."
[& body]
`(let [s# (new java.io.StringWriter)]
(binding [clojure.test/*test-out* s#]
~@body
(str s#))))
slagyr/speclj
(ns speclj.report.clojure-test-spec
(:require ;cljs-macros
[clojure.string :as str]
[clojure.test]
;cljs-include [goog.string] ;cljs bug?
[speclj.components :refer [new-characteristic new-description]]
[speclj.core :refer [-new-exception -new-failure describe it should-contain should= with]]
[speclj.report.clojure-test :refer [new-clojure-test-reporter]]
[speclj.reporting :refer [report-error report-fail report-pass report-pending report-runs]]
[speclj.results :refer [error-result fail-result]]
[speclj.run.standard :refer [run-specs]]))
(defmacro with-test-out-str [& body]
`(let [s# (new java.io.StringWriter)]
(binding [clojure.test/*test-out* s#]
~@body
(str s#))))
hyperfiddle/rcf
(ns hyperfiddle.rcf.reporters
(:require [clojure.test :as t]
[clojure.string :as str]))
(defmethod t/report :hyperfiddle.rcf/fail [m]
(print "❌ ")
(print (str/triml (with-out-str
(binding [t/*test-out* *out*]
(t/report (assoc m :type :fail)))))))
sritchie/midje-cascalog
(deftask midje
"Run midje and clojure.test tests"
(bake (:use [bake.core :only [with-context]])
(:require [clojure test string])
[namespaces (concat (find-namespaces-in-dir (java.io.File. "test"))
(find-namespaces-in-dir (java.io.File. "src")))]
(with-context :test
;; This turns off "Testing ...." lines, which I hate, especially
;; when there's no failure output.
(defmethod clojure.test/report :begin-test-ns [m])
; Stashed clojure.test output
clojure-test-output-catcher
(java.io.StringWriter.)
clojure-test-result
(binding [clojure.test/*test-out* clojure-test-output-catcher]
(apply clojure.test/run-tests namespaces))
clojure-test-output
(-> clojure-test-output-catcher .toString clojure.string/split-lines)]
ldnclj/Coloured-Balls
(deftask midje
"Run midje and clojure.test tests"
(bake (:use [bake.core :only [with-context]])
(:require [clojure test string])
[namespaces (concat (find-namespaces-in-dir (java.io.File. "test"))
(find-namespaces-in-dir (java.io.File. "src")))]
(with-context :test
;; This turns off "Testing ...." lines, which I hate, especially
;; when there's no failure output.
(defmethod clojure.test/report :begin-test-ns [m])
; Stashed clojure.test output
clojure-test-output-catcher
(java.io.StringWriter.)
clojure-test-result
(binding [clojure.test/*test-out* clojure-test-output-catcher]
(apply clojure.test/run-tests namespaces))
clojure-test-output
(-> clojure-test-output-catcher .toString clojure.string/split-lines)]