CrossClj

0.0.5 docs

SourceDocs



RECENT

    clj-async-test

    Clojars

    Apr 17, 2016


    OWNER
    Markus Hjort
    @TomorrowLabs
    Helsinki
    twitter.com/mhjort

    Readme

    Index of all namespaces


    « Project + dependencies

    clojure.test assertions for testing asynchronous code

    The README below is fetched from the published project artifact. Some relative links may be broken.

    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.