A spartan test framework compatible with babashka (>= 0.0.65) and Clojure.
Currently babashka doesn't have an implementation of clojure.test
. This
library can be used meanwhile.
NOTE: babashka (>= 0.0.67) now has clojure.test
as a built-in namespace, which deprecates this library.
Currently this library only supports deftest
, is
, testing
, thrown?
,
thrown-with-msg?
and run-tests
. Tests can only be defined through
deftest
, not via metadata on vars.
Usage in a deps.edn
project:
{:deps {borkdude/spartan.test {:mvn/version "0.0.5"}}
:aliases {:test-namespaces {:main-opts ["-m" "spartan.test" "-n" "project.test"]}
:test-vars {:main-opts ["-m" "spartan.test" "-v" "project.test/bar-test"]}}}
$ cat src/project/core.clj
(ns project.core)
(defn foo []
1)
$ cat src/project/test.clj
(ns project.test
(:require
[project.core :as project]
[spartan.test :as test :refer [deftest is]]))
(deftest foo-test
(is (= 1 (project/foo)))
(is (= 2 (project/foo))))
(deftest bar-test
(is (= 1 (project/foo))))
Run with deps.clj:
$ deps.clj -A:test-namespaces -Scommand "bb -cp {{classpath}} {{main-opts}}"
FAIL in project.test/foo-test
expected: (= 2 (project/foo))
actual: (not (= 2 1))
Ran 2 tests containing 3 assertions.
1 failures, 0 errors.
$ deps.clj -A:test-vars -Scommand "bb -cp {{classpath}} {{main-opts}}"
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
Install babashka and deps.clj.
Then run script/test
.
Copyright © 2019 Michiel Borkent
Distributed under the EPL License. See LICENSE.