Liking cljdoc? Tell your friends :D

Kaocha plugin test-ns-hook

  • This plugin test-ns-hook for Kaocha mimics the test-ns-hook feature in clojure.test

1. How to install

To include this plugin for Kaocha in your project, simply add the following to your project.clj dependencies:

[org.clojars.philoskim/test-ns-hook "0.2.1"]

2. Use example

;; project.clj for lein
(defproject my-project "0.1.0"
  :dependencies [[org.clojure/clojure "1.11.1"]
                 [lambdaisland/kaocha "1.87.1366"]
                 [org.clojars.philoskim/test-ns-hook "0.2.1"]]
  :aliases {"unit-test" ["run" "-m" "kaocha.runner" ":unit"]})
;; tests.edn for Kaocha
{:kaocha/tests
 [{:kaocha.testable/type :kaocha.type/clojure.test,
   :kaocha.testable/id :unit,
   :kaocha/ns-patterns ["-test$"],
   :kaocha/source-paths ["src"],
   :kaocha/test-paths ["test"],
   :kaocha.filter/skip-meta [:kaocha/skip]}]
 :kaocha/fail-fast? false,
 :kaocha/color? true,
 :kaocha/cli-options {:config-file "tests.edn", :print-config true},
 :kaocha.plugin.randomize/randomize? false,
 :kaocha/plugins [:kaocha.plugin/filter
                  :philoskim.kaocha.plugin/test-ns-hook],
 :kaocha.plugin.capture-output/capture-output? false,
 :kaocha/reporter [kaocha.report/dots]}
;; test/my-test
(ns my-test
  (:require [clojure.test :refer :all]))

(deftest test-a
  (testing "test-a"
    (is (= 1 1))
    (is (= (+ 2 2) 5)) ))

(deftest test-b
  (testing "test-b"
    (is (= 10 10))
    (is (= 20 20))))

(defn test-ns-hook []
  (test-a)
  (test-b))
$ lein unit-test
[(.F..)]

FAIL in my-test/test-ns-str (my_test.clj:15)
test-a
Expected:
  4
Actual:
  -4 +5
1 tests, 4 assertions, 1 failures.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close