项目作者: borkdude

项目描述 :
A spartan test framework compatible with babashka.
高级语言: Clojure
项目地址: git://github.com/borkdude/spartan.test.git
创建时间: 2019-12-29T13:15:25Z
项目社区:https://github.com/borkdude/spartan.test

开源协议:Eclipse Public License 1.0

下载


spartan.test

CircleCI
Clojars Project
project chat

A spartan test framework compatible with
babashka (>= 0.0.65) and Clojure.

Rationale

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.

Differences with clojure.test

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:

Usage in a deps.edn project:

  1. {:deps {borkdude/spartan.test {:mvn/version "0.0.5"}}
  2. :aliases {:test-namespaces {:main-opts ["-m" "spartan.test" "-n" "project.test"]}
  3. :test-vars {:main-opts ["-m" "spartan.test" "-v" "project.test/bar-test"]}}}
  1. $ cat src/project/core.clj
  2. (ns project.core)
  3. (defn foo []
  4. 1)
  5. $ cat src/project/test.clj
  6. (ns project.test
  7. (:require
  8. [project.core :as project]
  9. [spartan.test :as test :refer [deftest is]]))
  10. (deftest foo-test
  11. (is (= 1 (project/foo)))
  12. (is (= 2 (project/foo))))
  13. (deftest bar-test
  14. (is (= 1 (project/foo))))

Run with deps.clj:

  1. $ deps.clj -A:test-namespaces -Scommand "bb -cp {{classpath}} {{main-opts}}"
  2. FAIL in project.test/foo-test
  3. expected: (= 2 (project/foo))
  4. actual: (not (= 2 1))
  5. Ran 2 tests containing 3 assertions.
  6. 1 failures, 0 errors.
  7. $ deps.clj -A:test-vars -Scommand "bb -cp {{classpath}} {{main-opts}}"
  8. Ran 1 tests containing 1 assertions.
  9. 0 failures, 0 errors.

Tests

Install babashka and deps.clj.
Then run script/test.

License

Copyright © 2019 Michiel Borkent

Distributed under the EPL License. See LICENSE.