dimanche 24 janvier 2016

Is this an acceptable way to test core.async functionality?

Consider the following unit-test snippet:

(deftest async-test
 (testing "Testing some core.async functionality."
  (go (is (= (<! (go "val")) "val1")))))

Running the test yields:

Ran 1 tests containing 0 assertions. 0 failures, 0 errors.

FAIL in () (at repl:253:51) expected: (= (<! (go "val")) "val1")  
actual: (not (= "val" "val1"))

But this is weird because: (i) there is 1 assertion in this test, yet the test output says there are 0, and (ii) the test statement also says there were 0 failures, even though there was 1 failure.

I suppose this is because the (is...) assertion is in a go block. So my question is, is this the best way to go about unit testing with core.async functionality? Is there some best practice here I'm missing?

Aucun commentaire:

Enregistrer un commentaire