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 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?
>> 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 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 different
>>> things based on that behaviour.  Pretty much every test has a different
>>> bloomy, *and* that bloomy must be elegantly shut down.
>>>
>>> How should I handle this?
>>>
>>> At the moment I have the most un-idiomatic way and blunt way of :
>>>
>>> [code]
>>> (deftest my-test
>>>   (let [bloomy (create-a-bloomy]
>>>   (try
>>>     (do-something-with-my-bloomy)
>>>     (is (=....))
>>>   (finally (shut-down bloomy))))
>>> [/code]
>>>
>>> Yep, try/finally in every test - reminds me of early JDBC libraries
>>> before Spring :).  If I understand it correctly, I would end up writing a
>>> separate fixture for each and every test, or at least each any every unique
>>> set of test context.
>>>
>>> I did consider writing a "(defn with-bloomy [bloomy test] (try (test)
>>> (finally (shut-down bloomy))))" but I couldn't figure out how to pass my
>>> bloomy into the test itself.  I also received lots of "assertion not in
>>> expectation" type errors.  To be explicit I would use this as "(with-bloomy
>>> (create-a-bloomy) (deftest...)))".
>>>
>>> I did consider a variation on the above of passing in a function which
>>> only contained the assertions, so "(deftest my-test (let [bloomy...]
>>> (with-bloomy bloomy #(is (= 1 (get-something bloomy)))))" but I also ran
>>> into similar "assertion not in expectation" type errors, and the
>>> indentation in emacs was insane.
>>>
>>> I expect a macro might be the answer?
>>>
>>> So, how would you solve this?
>>>
>>> --
>>> --
>>> 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
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> --
>> 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
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Clojure" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/clojure/Pm-DUDxWeM4/unsubscribe?hl=en.
>> To unsubscribe from this group and all its topics, send an email to
>> clojure+unsubscr...@googlegroups.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to