Fork me on GitHub

Hi, I’m wondering how I could write tests for functions that use core.async. Say I have the following function:

(defn foo
    (a/<! (a/timeout 1000))
There is a similar question on Stack Overflow: Is it possible to write a test, that * fails if the channel returned by foo does not provide any value within 5 seconds, * fails if the channel provides anything else than 42, * fails if the channel does not close after providing 42, * does not block other tests from running? (That’s the hard part!)


looking at the example in the stack overflow post, my immediate reaction is his mistake is using the go macro in a test


use the blocking <!! and >!! and alts!!!!! (or however many bangs it is) in tests


there is no reason not to, and your tests will be simpler for it