Skip to content

Instantly share code, notes, and snippets.

@mrroman
Created December 7, 2018 11:00
Show Gist options
  • Save mrroman/40ccf400fd312fbf0bdb7baf19a2778f to your computer and use it in GitHub Desktop.
Save mrroman/40ccf400fd312fbf0bdb7baf19a2778f to your computer and use it in GitHub Desktop.
Simple/fast CLI test runner for all your tests
(ns test
(:require [clojure.java.io :as io]
[clojure.string :as str]
[clojure.test :as t]))
(defonce test-folder "test")
(defonce test-filter #"^myapp.*$")
(defn test-file? [path]
(str/ends-with? path "_test.clj"))
(defn load-tests []
(->> (file-seq (io/file test-folder))
(filter (memfn isFile))
(map (memfn getPath))
(filter test-file?)
(sort)
(map #(do
(println "Loading" %)
(load-file %)))
(doall)))
(defn -main []
(println "Loading tests...")
(load-tests)
(println "Running tests...")
(try
(t/run-all-tests test-filter)
(finally
(shutdown-agents))))
@mrroman
Copy link
Author

mrroman commented Dec 7, 2018

Put it in your dev directory and add an alias to deps.edn, e.g.:

{:aliases
  {:test {:extra-paths ["dev" "test"]}}}

Run it with:

clojure -Atest -m test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment