https://github.com/borkdude/missing.test.assertions
A library that detects missing test assertions in clojure.test tests
https://github.com/borkdude/missing.test.assertions
clojure testing
Last synced: 22 days ago
JSON representation
A library that detects missing test assertions in clojure.test tests
- Host: GitHub
- URL: https://github.com/borkdude/missing.test.assertions
- Owner: borkdude
- License: epl-1.0
- Created: 2019-11-04T18:46:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T22:41:43.000Z (almost 6 years ago)
- Last Synced: 2025-06-06T10:53:11.561Z (7 months ago)
- Topics: clojure, testing
- Language: Clojure
- Homepage:
- Size: 16.6 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# missing.test.assertions
[](https://clojars.org/borkdude/missing.test.assertions)
[](https://cljdoc.org/d/borkdude/missing.test.assertions/CURRENT)
Library for checking absence of assertions in
[clojure.test](https://clojure.github.io/clojure/clojure.test-api.html) 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`.
``` clojure
(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*`:
``` clojure
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-var` and
`:end-test-var` hooks, call `missing.test.assertions/register!` afterwards. This will
redefine the `missing.test.assertions` hooks 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](https://github.com/lambdaisland/kaocha) has this as a built-in feature
## License
Copyright © 2019 Michiel Borkent
Distributed under the EPL License, same as Clojure. See LICENSE.