Thanks for the reply Jarkko, Yes I can work around it. The scenario is that I want to see a message correctly passed: http://github.com/timothypratley/strive/blob/cef5a3a9ea18159f866fe6c94603b704daba1ba8/clj/timothypratley/test-messenger.clj It is useful (tempting?) in this case to be able to check something on a thread, but I can save the value and check it later to avoid doing so.
Regarding futures not raising exceptions, this is actually completely independent of test. From experimentation, exceptions on futures are only reported if the future is @ examined (presumably by design). So I think my options are to wrap long running futures in a try/catch/ report or use a normal Thread. Regards Tim. On Jul 6, 7:52 pm, Jarkko Oranen <chous...@gmail.com> wrote: > 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 -~----------~----~----~----~------~----~------~--~---