Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.
/ spartan.test Public archive

A spartan test framework compatible with babashka.

License

Notifications You must be signed in to change notification settings

borkdude/spartan.test

Repository files navigation

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:

{: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.

Tests

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

License

Copyright © 2019 Michiel Borkent

Distributed under the EPL License. See LICENSE.

About

A spartan test framework compatible with babashka.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published