missing.test.assertions
November 11, 2019 · View on GitHub
Library for checking absence of assertions in clojure.test tests.
Usage
Require missing.test.assertions in your test namespace(s).
Note that in a-test no assertions are made, but another-test has one
assertion. So we expect a warning only about a-test.
(ns foo.core-test
(:require [clojure.test :refer [deftest testing is]]
[missing.test.assertions]))
(deftest a-test
(testing "..."
1))
(deftest another-test
(testing (is 1)))
When executing the tests, the following warning will get printed to *err*:
WARNING: no assertions made in test a-test
Notes
- This library works with Clojure and ClojureScript.
- When registering your own
clojure.test/report:begin-test-varand:end-test-varhooks, callmissing.test.assertions/register!afterwards. This will redefine themissing.test.assertionshooks while your hooks keep working. - The default behavior in absence of test assertions is printing a message. If you want an exception, call
(missing.test.assertions/register! {:throw? true}).
Test
JVM
lein test
or
clj -A:test
Node
script/test/node
Related projects
- kaocha has this as a built-in feature
License
Copyright © 2019 Michiel Borkent
Distributed under the EPL License, same as Clojure. See LICENSE.