On Jul 6, 7:51 am, Timothy Pratley <timothyprat...@gmail.com> wrote:
> Very glad that test is now part of clojure core.
>
> I've run into 2 strange behaviours when trying to write tests where
> threads are involved. My case is a little complex so here is a minimal
> version which shows what I mean:
>
> test-test.clj:
> (ns test-test
>   (:use clojure.test))
>
> (deftest testathon
>   (let [f1 (future (is (= 1 2)))
>         f2 (future (future (/ 1 0)))]
>     @f1
>     @f2))
>
> (run-tests)
> (shutdown-agents)
>
> $ clj test-test.clj
>
> Testing test-test
>
> FAIL in clojure.lang.persistentlist$emptyl...@1 (test-test.clj:5)
> expected: (= 1 2)
>   actual: (not (= 1 2))
>
> Ran 1 tests containing 0 assertions.
> 0 failures, 0 errors.
>
> f1 failed, and a FAIL message is printed, but the end report indicates
> 0 failures.
> f2 raised an exception silently.
>
> I guess I'm just not "doing it right"!
>

Are you sure you don't want to test something like
(let [v (future (+ 1 2))]
  (is (= @v 3)))
instead? My guess is that having 'is inside a future messes up the per-
thread bindings that clojure.test uses. I don't know if there's a way
around that, but also doubt assertions inside futures are really
useful.

> Regards,
> Tim.

--
Jarkko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to