I've started a bit of a wrapper around EasyMock as part of Cascade
http://github.com/hlship/cascade/blob/master/src/main/clojure/cascade/mock.clj
Looks like this in practice:
(deftest test-parse-url-query-parameters
(with-mocks
[request HttpServletRequest]
(:train
(expect .getParameter request "buzby" "12345"))
(:test
(let [env {:servlet-api { :request request }}
result (parse-url env [b [:buzby :int]] b)]
(is (= (class result) Integer))
(is (= result 12345))))))
On Sun, Sep 27, 2009 at 7:21 AM, J. McConnell <[email protected]> wrote:
> On Sun, Sep 27, 2009 at 12:55 AM, Mark Derricutt <[email protected]> wrote:
>>
>> How are people handling mocking/stubbing in clojure?
>
> For mocking clojure code, I would have a look at clojure.contrib.mock (1). I
> haven't used it, but plan to check it out soon. Recently, while doing some
> performance testing of some Java code, I had good results using proxy for a
> stub and EasyMock for mocks. It was a one-off thing though, I so I don't
> have any useful wrappers for EasyMock to show for it.
>
> HTH,
>
> - J.
>
> 1) http://richhickey.github.com/clojure-contrib/mock-api.html
>
>
> >
>
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---