Structing Clojure tests/setup and tear down

2013-05-21 Thread Colin Yates
Howdy, I am using clojure.test and have some questions of how to write idiomatic Clojure. This really isn't about testing at all per-se. First - I know about fixtures to get (at least) the same as JUnit's before/after behaviour. My code is a bloomy. You can configure the bloomy and it does

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Ulises
Perhaps you're looking for fixtures? http://thornydev.blogspot.co.uk/2012/09/before-and-after-logic-in-clojuretest.html U On 21 May 2013 15:17, Colin Yates colin.ya...@gmail.com wrote: Howdy, I am using clojure.test and have some questions of how to write idiomatic Clojure. This really

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Colin Yates
Hi Ulises, I don't think I am as that would require essentially a fixture per distinct combinations of test state, which is almost the same number of tests. Have I missed something? On 21 May 2013 15:51, Ulises ulises.cerv...@gmail.com wrote: Perhaps you're looking for fixtures?

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread gaz jones
I think I would use a macro: (defn with-bloomy-fn [bloomy body] (try (body) (finally (shut-down bloomy (defmacro with-bloomy [bloomy body] `(with-bloomy-fn ~bloomy (fn [] ~@body))) (deftest my-test (with-bloomy (create-a-bloomy) (...)) FYI code is untested, typing

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Colin Yates
Thanks Gaz, I was expecting a macro to be the answer, and seeing how you have used a macro to glue together two functions is really helpful, so thanks a bunch! On 21 May 2013 16:21, gaz jones gareth.e.jo...@gmail.com wrote: I think I would use a macro: (defn with-bloomy-fn [bloomy body]

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Ulises
Hey Colin, Apologies, I missed your First - I know about fixtures... line :) I'd probably +1 Gaz's macro (I've not tested it either but it looks reasonable.) On 21 May 2013 16:05, Colin Yates colin.ya...@gmail.com wrote: Hi Ulises, I don't think I am as that would require essentially a

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Colin Yates
No worries ;) On 21 May 2013 17:18, Ulises ulises.cerv...@gmail.com wrote: Hey Colin, Apologies, I missed your First - I know about fixtures... line :) I'd probably +1 Gaz's macro (I've not tested it either but it looks reasonable.) On 21 May 2013 16:05, Colin Yates

Re: Structing Clojure tests/setup and tear down

2013-05-21 Thread Alex Baranosky
I tend to have macros for different types of setup/teardowns. Mostly because clojure.test fixtures always want to wrap *every* test in a file. On Tue, May 21, 2013 at 9:41 AM, Colin Yates colin.ya...@gmail.com wrote: No worries ;) On 21 May 2013 17:18, Ulises ulises.cerv...@gmail.com wrote: