Back
run-tests (clj)
(source)function
(run-tests)
(run-tests & namespaces)
Runs all tests in the given namespaces; prints results.
Defaults to current namespace if none given. Returns a map
summarizing test results.
Examples
cognitect-labs/vase
(require '[clojure.test :refer [run-tests]])
(deftask test
"Run project tests"
[]
(with-test) ;; test source paths and test/dev deps added
(require '[clojure.tools.namespace.find :refer [find-namespaces-in-dir]])
(let [find-namespaces-in-dir (resolve 'clojure.tools.namespace.find/find-namespaces-in-dir)
test-nses (->> (get-env :test-paths)
(mapcat #(find-namespaces-in-dir (clojure.java.io/file %)))
distinct)]
(doseq [tns test-nses] (require tns))
(apply clojure.test/run-tests test-nses)))
candera/khordr
(require '[clojure.test :refer :all]
'[khordr.handler :as h]
'[khordr.handler.modifier-alias :refer :all]
'[khordr.effect :as e]
'[khordr.test.handler :refer :all])
(test/run-tests 'khordr.test.handler.modifier-alias)
johnlawrenceaspden/hobby-code
(require 'helloweb)
(require 'clojure.test)
(clojure.test/run-tests 'helloweb)
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)]
adzerk-oss/boot-logservice
(require '[adzerk.bootlaces :refer :all]
'[clojure.test :as test :refer [deftest is run-tests]]
'[adzerk.boot-logservice :as log-service]
'[clojure.tools.logging :as log])
(ns-unmap 'boot.user 'test)
(deftask test []
(with-pre-wrap fileset
(let [log-dir (tmp-dir!)
config [:configuration {:scan true, :scanPeriod "10 seconds"}
[:appender {:name "FILE" :class "ch.qos.logback.core.rolling.RollingFileAppender"}
[:encoder [:pattern "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"]]
[:rollingPolicy {:class "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"}
[:fileNamePattern (str (.getPath log-dir) "/%d{yyyy-MM-dd}.%i.log")]
[:timeBasedFileNamingAndTriggeringPolicy {:class "ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"}
[:maxFileSize "64 MB"]]]
[:prudent true]]
[:root {:level "INFO"}
[:appender-ref {:ref "FILE"}]]]]
(alter-var-root #'log/*logger-factory* (constantly (log-service/make-factory config)))
(deftest log-file-created
(log/info "This should result in a log file being created on disk.")
(log/with-logs 'some.ns (println "This should work too"))
(let [logs (.listFiles log-dir)]
(is (= 1 (count logs)))
(println "Log file content:" (slurp (first logs)))))
(let [report (run-tests 'boot.user)]
(if-not (every? zero? (map report [:fail :error]))
(throw (ex-info "Tests failed" report))))
(-> fileset
(add-resource log-dir)
commit!))))