clojure.test assertions for testing asynchronous code
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/clj_async_test
test/clj_async_test
.gitignore
LICENSE
README.md
project.clj

README.md

clj-async-test

clojure.test assertions for testing asynchronous code

Installation

Add the following to your project.clj :dependencies:

[clj-async-test "0.0.5"]

Usage

Following test pass immediately if predicate '(= actual expected) is true. Otherwise test runner tries it multiple times and fails if it does not pass in one second.

(require '[clj-async-test :refer :all])

(is (eventually (= actual expected)))

Sometimes when testing asynchronous code it is hard to test with exact numbers. It's enough when something is approximately right. Following test pass if difference between actual and expected is less than 1%.

(require '[clj-async-test :refer :all])

(is (approximately== actual expected))

You can also set the desired accuracy.

(is (approximately== actual expected :accuracy 5))

License

Copyright (C) 2015-2016 Markus Hjort

Distributed under the Eclipse Public License, the same as Clojure.