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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.