mmcgrana / clj-unit
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
clj-unit /
| name | age | message | |
|---|---|---|---|
| |
LICENSE | ||
| |
README.md | ||
| |
project.clj | ||
| |
src/ |
README.md
clj-unit is a simple unit testing library for Clojure. The goal of clj-unit is to provide a non-magical, developer-friendly unit testing API along with a wide variety of assertion helpers.
Features
- Extremely small core implementation with a simple interface.
- Pluggable reporters, with a built-in console reporter that uses clj-stacktrace to provide trimmed, cleaned, and colorized backtraces on unit test errors.
- Stateless facade for reporters, eliminating the need for them to maintain their own global state.
- Many built in assertions.
- New assertions can be implemented as stand-alone functions; they don't need to be methods or macros.
Available Assertions
assert=assert-not=assert-in-deltaassert-thatassert-notassert-nilassert-fnassert-not-fnassert-instanceassert-isaassert-matchassert-throwsflunk(always fails)success,failure,assert-truth(for defining custom assertions)
Example
(ns myapp.utils-test
(:use clj-unit.core))
(deftest "re-match?"
(assert-that (re-match? #"o" "foo"))
(assert-not (re-match? #"bar" "foo")))
(deftest "url-escape, url-unescape: round-trip as expected"
(let [given "foo123!@#$%^(){}[]?/"]
(assert= given (url-unescape (url-escape given)))))
(deftest "check-keys: throws on unrecognized keys"
(assert-throws #"unrecognized keys"
(check-keys {:foo "bar" :fiz "bat"} [:foo :bar])))
(run-tests 'myapp.utils-test)
License
Copyright 2009 Mark McGranaghan and released under an MIT license.

