Mocking framework

58 views
Skip to first unread message

Erik Bakstad

unread,
Jun 28, 2011, 2:56:38 AM6/28/11
to Clojure
Hi, I'm currently working on my first real Clojure project, and I find
myself wanting a mocking tool. So I was wondering what you are using?
I tried googling, but I can't seem to find the "Mockito of the clojure
world". Searching for a mocking tool in Clojure it looks like there is
a lot of small tools being thrown together, but maybe not being used
by many? The one exception maybe is https://github.com/marick/Midje?

Thanks, Erik.

Ola Ellnestam

unread,
Jun 28, 2011, 3:52:51 AM6/28/11
to clo...@googlegroups.com
Hi Erik,

Take a closer look at Midje, especially
https://github.com/marick/Midje/wiki/Metaconstants

I'm not an subject matter expert but to me it's close enough to
mocking/stubbing.

Cheers,
Ola


--
---------------------------------------------------------
Ola Ellnestam
Agical AB
V�sterl�nggatan 79, 2 tr
111 29 Stockholm, SWEDEN

Mobile: +46-708-754000
E-mail: ola.el...@agical.se
Blog: http://ellnestam.wordpress.com
Twitter: ellnestam

gaz jones

unread,
Jun 28, 2011, 8:17:12 AM6/28/11
to clo...@googlegroups.com
jay fields has a good blog post on this:

http://blog.jayfields.com/2010/09/clojure-mocking.html

On Tue, Jun 28, 2011 at 2:52 AM, Ola Ellnestam <ola.el...@agical.se> wrote:
> Hi Erik,
>
> Take a closer look at Midje, especially
> https://github.com/marick/Midje/wiki/Metaconstants
>
> I'm not an subject matter expert but to me it's close enough to
> mocking/stubbing.
>
> Cheers,
> Ola
>
> Erik Bakstad skrev 2011-06-28 08:56:
>>
>> Hi, I'm currently working on my first real Clojure project, and I find
>> myself wanting a mocking tool. So I was wondering what you are using?
>> I tried googling, but I can't seem to find the "Mockito of the clojure
>> world". Searching for a mocking tool in Clojure it looks like there is
>> a lot of small tools being thrown together, but maybe not being used
>> by many? The one exception maybe is https://github.com/marick/Midje?
>>
>> Thanks, Erik.
>>
>
>
> --
> ---------------------------------------------------------
> Ola Ellnestam
> Agical AB

> Västerlånggatan 79, 2 tr


> 111 29 Stockholm, SWEDEN
>
> Mobile: +46-708-754000
> E-mail: ola.el...@agical.se
> Blog: http://ellnestam.wordpress.com
> Twitter: ellnestam
>

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

László Török

unread,
Jun 28, 2011, 8:23:14 AM6/28/11
to clo...@googlegroups.com
...and a classic (not clojure specific)

http://codebetter.com/gregyoung/2008/02/13/mocks-are-a-code-smell/

(Disclaimer: I don't necessarily share Greg's opinion, but interesting nonetheless)

2011/6/28 gaz jones <gareth....@gmail.com>



--
László Török

Skype: laczoka2000
Twitter: @laczoka

Brian Marick

unread,
Jun 28, 2011, 5:30:48 PM6/28/11
to clo...@googlegroups.com

On Jun 28, 2011, at 7:23 AM, László Török wrote:

> ...and a classic (not clojure specific)
>
> http://codebetter.com/gregyoung/2008/02/13/mocks-are-a-code-smell/

One thing I'm trying to emphasize with Midje is that mocking in the context of a functional language is (can be) about the logical connections among functions in a system. That's why Midje avoids test terminology in favor of something that looks more logic/Prolog-ish. As a simple example:

(fact "ratings of movies with favorite actors are bumped a bit higher"
(rating ...movie...) => (roughly (* 1.2 4.0))
(provided
(critic-rating ...movie...) => 4.0
(intersection (actors ...movie...) (favorite-actors)) =not=> empty?)))

Mike Feathers and I will be having a presentation about "tests as a means of abstraction" at Agile2011
http://program2011.agilealliance.org/event/873f7801c8b4f23fc1f0cfe0a45de2f5
and I've submitted a derivative session to Clojure Conj.

[Besides sometimes allowing the removal of even more incidental complexity than straight clojure code does, another "means of abstraction" is deferring decisions about data structures. In the above, we don't have to know anything about what a "movie" is except that `critic-rating` and `actors` work with it, which is saying something like what `defprotocol` says.]

-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick

Reply all
Reply to author
Forward
0 new messages