[ANN] Shrubbery 0.4.0, a stubbing, spying, and mocking library for Clojure protocols

2016-08-22 Thread Brian Guthrie
Clojure protocols are a great way to encapsulate operations with side effects, but suffer from a lack of general test tooling. Shrubbery provides a small set of basic building blocks for working with them. New in this release: – A throws function, which returns an object suitable for use with

Re: [ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-06 Thread Brian Guthrie
On Tue, Oct 6, 2015 at 6:16 AM, Atamert Ölçgen wrote: > It would be great if multiple return values for multiple calls were > supported. First use case it something like an iteration, calling some > protocol method repeatedly (possibly with different inputs). Another use > case

Re: [ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-06 Thread Atamert Ölçgen
This is awesome! I might have more useful feedback (and PRs) in the future, because I can see myself using this extensively. It would be great if multiple return values for multiple calls were supported. First use case it something like an iteration, calling some protocol method repeatedly

Re: [ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread Brian Guthrie
Great to hear! Let me know if there are any questions I can answer. Feedback gratefully accepted. Cheers, Brian On Mon, Oct 5, 2015 at 11:56 AM, James Reeves wrote: > Very nice. I was looking for something like this. > > - James > > On 5 October 2015 at 15:14, Brian

[ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread Brian Guthrie
Clojure protocols are a great way to encapsulate operations with side effects, but suffer from a lack of general test tooling. Shrubbery provides a small set of basic building blocks for working with them: * stub, which accepts a variable list of protocols and a optional hashmap of simple value

Re: [ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread James Reeves
Very nice. I was looking for something like this. - James On 5 October 2015 at 15:14, Brian Guthrie wrote: > Clojure protocols are a great way to encapsulate operations with side > effects, but suffer from a lack of general test tooling. Shrubbery provides > a small set of

[ANN] Shrubbery 0.2.0, a stubbing, spying, and mocking library for Clojure protocols

2015-05-09 Thread Glen Mailer
This looks neat Brian! People who find this useful may also like a similar lib I wrote that provides mocking tools at a single function level: https://github.com/glenjamin/q -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

[ANN] Shrubbery 0.2.0, a stubbing, spying, and mocking library for Clojure protocols

2015-05-08 Thread Brian Guthrie
Clojure protocols are a great way to encapsulate operations with side effects, but suffer from a lack of general test tooling. Shrubbery provides a small set of basic building blocks for working with them: * stub, which accepts a protocol and a hashmap of functions and returns an implementation

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-08 Thread Allen Rohner
On Wednesday, January 7, 2015 at 2:49:50 PM UTC-6, Sean Corfield wrote: On Jan 7, 2015, at 10:21 AM, Allen Rohner aro...@gmail.com javascript: wrote: As a design rule, I prefer making I/O fns (things that hit the DB or a REST API), 'dumb', and perform all logic/processing in fns that

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-07 Thread Sean Corfield
On Jan 7, 2015, at 10:21 AM, Allen Rohner aroh...@gmail.com wrote: As a design rule, I prefer making I/O fns (things that hit the DB or a REST API), 'dumb', and perform all logic/processing in fns that just receive plain data, and return plain data. I’m curious: do you have wrapper functions

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-07 Thread Allen Rohner
On Wednesday, December 31, 2014 8:48:27 AM UTC-6, Jonathon McKitrick wrote: I use TDD and mocking/stubbing (conjure) to test each layer of my code. The problem is when I change the function signature and the tests do not break, because the mocks/stubs do not know when their argument lists

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Akos Gyimesi
On Sat, Jan 3, 2015, at 02:46 AM, Brian Marick wrote: I use TDD and mocking/stubbing (conjure) to test each layer of my code. The problem is when I change the function signature and the tests do not break, because the mocks/stubs do not know when their argument lists no longer agree

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Colin Yates
I don't think there is an easy answer here, and note that this is a problem generic to mocking (i.e. not clojure or midje specific). The usual advice applies though: - do you really need to mock? Unit testing is about the coarseness of granularity which is defined more by cohesion

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Jonathon McKitrick
AM, Brian Marick wrote: I use TDD and mocking/stubbing (conjure) to test each layer of my code. The problem is when I change the function signature and the tests do not break, because the mocks/stubs do not know when their argument lists no longer agree with the underlying function

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Timothy Baldridge
as contract tests. Here's a diagram of the problem: login - check-pw I've found that most code that uses mocking will test the login and the check-pw bits, but completely neglect testing the arrow between them, and when that happens, you get exactly the experience you described. The other

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Colin Yates
a test that pairs a login form with a check-pw and runs tests against this system. Some people call these tests integration tests or system tests. But I think of them as contract tests. Here's a diagram of the problem: login - check-pw I've found that most code that uses mocking will test

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Akos Gyimesi
Thank you for all the responses! To be honest, I hoped that someone would explain why this mocking style is a good thing, and I just misunderstand something about the top-down development that the Midje wiki suggests: https://github.com/marick/Midje/wiki/The-idea-behind-top-down-development

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Brian Marick
Akos Gyimesi wrote: Now, later that day I decide that I pass the whole user object to the check-pw function. Maybe I want to use the user ID as a salt, or maybe I just want to leave the possibility for checking password expiration, etc. So I modify the test and the implementation of check-pw so

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Brian Marick
the mocking features for unfinished code (they are indeed convenient in Midje), but remove them immediately after the lower-level components are implemented. I believe some people do that. I don't. The main reason is that doing so will very often require spending time setting up data. My coding

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-05 Thread Colin Yates
...@exampler.com javascript: wrote: Timothy Baldridge wrote: I don't recommend Midje at all. Many of the framework's mocking facilities (such as providing) are abominations. Hacker News notwithstanding, idiosyncratic interface is not a synonym for abomination. It may look cute

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-05 Thread Sam Ritchie
Agreed, Timothy - obviously the mental model gets more tangled when state mocking comes into play, but the fact is, sometimes you don't have the option (right away) of rewriting the code you're testing. Midje has been great for the Cascalog community: http://www.samritchie.io/testing-cascalog

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-05 Thread Timothy Baldridge
more tangled when state mocking comes into play, but the fact is, sometimes you don't have the option (right away) of rewriting the code you're testing. Midje has been great for the Cascalog community: http://www.samritchie.io/testing-cascalog-with-midje/ http://www.samritchie.io/cascalog

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-04 Thread Brian Marick
running clojure.test tests, making it easy to migrate when you get tired of writing your own functions to compare expected to actual results in different ways. It's also reasonable to simply not use the mocking parts of Midje (or other frameworks). Then you'll have clojure.test with a syntax you may

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-04 Thread Brian Marick
what's going to happen, so let me go check every test that calls foo, or calls something that calls foo to make sure it isn't overriding baz somehow. Here I have to disagree. Technically, I think the description is wrong, but the bit about mental model is more important. Midje's mocking behavior

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-03 Thread Timothy Baldridge
the factors I mentioned above (# of years using Clojure, # of years using Midje, do they still use it, etc). Timothy On Fri, Jan 2, 2015 at 6:55 PM, Brian Marick mar...@exampler.com wrote: Timothy Baldridge wrote: I don't recommend Midje at all. Many of the framework's mocking facilities

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-02 Thread Brian Marick
I use TDD and mocking/stubbing (conjure) to test each layer of my code. The problem is when I change the function signature and the tests do not break, because the mocks/stubs do not know when their argument lists no longer agree with the underlying function they are mocking. Is there a way

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-02 Thread Brian Marick
Timothy Baldridge wrote: I don't recommend Midje at all. Many of the framework's mocking facilities (such as providing) are abominations. Hacker News notwithstanding, idiosyncratic interface is not a synonym for abomination. It may look cute, but I've lost countless hours to bugs

How to handle refactoring with TDD and mocking/stubbing

2014-12-31 Thread Jonathon McKitrick
I use TDD and mocking/stubbing (conjure) to test each layer of my code. The problem is when I change the function signature and the tests do not break, because the mocks/stubs do not know when their argument lists no longer agree with the underlying function they are mocking. Is there a way

Re: How to handle refactoring with TDD and mocking/stubbing

2014-12-31 Thread Ashton Kemerling
:48 AM, Jonathon McKitrick jmckitr...@gmail.com wrote: I use TDD and mocking/stubbing (conjure) to test each layer of my code. The problem is when I change the function signature and the tests do not break, because the mocks/stubs do not know when their argument lists no longer agree

Re: How to handle refactoring with TDD and mocking/stubbing

2014-12-31 Thread Timothy Baldridge
mocking facilities (such as providing) are abominations. You shouldn't go around mucking with functions and re-deffing them on the fly. It may look cute, but I've lost countless hours to bugs and unexpected behavior related to Midje. IMO, stay clear of that. The pattern I do recommend is to break

Re: How to handle refactoring with TDD and mocking/stubbing

2014-12-31 Thread Sean Corfield
On Dec 31, 2014, at 8:24 AM, Timothy Baldridge tbaldri...@gmail.com wrote: This is one of the main reasons why I try to stay clear of heavy use of invasive mocks. I can't tell you the amount of times I've looked at code and realized that because of mocks nothing was really being tested at

Re: Mocking java class for test.

2014-12-15 Thread James Reeves
The easiest way would be to wrap the class constructor in a function and override that. - James On 15 December 2014 at 04:20, Eunmin Kim telepopso...@gmail.com wrote: Hi! My question is, How can I exchange a java class for test like `with-redefs`? (defn run-a [] (... some logic

Mocking java class for test.

2014-12-14 Thread Eunmin Kim
Hi! My question is, How can I exchange a java class for test like `with-redefs`? (defn run-a [] (... some logic (.run (AClass. ))) (deftest some-test (with-redefs [AClass MockAClass] ;; ??? (is (run-a))) -- You received this message because you are subscribed to the Google

Re: ANN - Conjure 2.1.1 - Lightweight mocking library

2012-12-01 Thread faenvie
... and could also fallback to using with-redefs. if it integrates well with core.contracts, test.generative etc. then its perfectly ok to use. thank you have successful time On Tuesday, November 27, 2012 9:22:29 AM UTC+1, Alex Baranosky wrote: Conjure is a lightweight mocking library intended

Re: ANN - Conjure 2.1.1 - Lightweight mocking library

2012-12-01 Thread Alex Baranosky
, test.generative etc. then its perfectly ok to use. thank you have successful time On Tuesday, November 27, 2012 9:22:29 AM UTC+1, Alex Baranosky wrote: Conjure is a lightweight mocking library intended to be used on top of clojure.test. We've been using it at Runa for a long time

Re: ANN - Conjure 2.1.1 - Lightweight mocking library

2012-11-30 Thread John Gabriele
On Tuesday, November 27, 2012 3:22:29 AM UTC-5, Alex Baranosky wrote: Conjure is a lightweight mocking library intended to be used on top of clojure.test. We've been using it at Runa for a long time, and it is compatible with all versions of Clojure from 1.2 to 1.5-beta1. https

ANN - Conjure 2.1.1 - Lightweight mocking library

2012-11-27 Thread Alex Baranosky
Conjure is a lightweight mocking library intended to be used on top of clojure.test. We've been using it at Runa for a long time, and it is compatible with all versions of Clojure from 1.2 to 1.5-beta1. https://github.com/amitrathore/conjure Alex -- You received this message because you

Re: Mocking out namespaces

2011-09-16 Thread Brian Hurt
On Thu, Sep 15, 2011 at 6:42 AM, Chris Perkins chrisperkin...@gmail.comwrote: On Wednesday, September 14, 2011 11:19:13 AM UTC-4, Brian Hurt wrote: Say I have two name spaces, A and B, with A depending on B. I want to test namespace A, replacing module B with a mock B for testing purposes-

Re: Mocking out namespaces

2011-09-16 Thread Stuart Sierra
On Friday, September 16, 2011 3:12:49 PM UTC-4, Brian Hurt wrote: How *should* I structure this code for testing? I was assuming the natural way to do this is to make A, B, and C separate name spaces but maybe this is wrong. The best way to make these namespaces testable, in my opinion,

Re: Mocking out namespaces

2011-09-16 Thread Chris Perkins
assurance it still works. So load it up into a repl and play with it isn't a viable solution. Or is clojure code just not testable/maintainable? Brian I don't have a detailed answer because I haven't done much mocking myself, but I'm confident that it's possible. The reason for my

Re: Mocking out namespaces

2011-09-16 Thread Brian Hurt
* the code- I need to be able to change this code later, and have some assurance it still works. So load it up into a repl and play with it isn't a viable solution. Or is clojure code just not testable/maintainable? Brian I don't have a detailed answer because I haven't done much mocking

Re: Mocking out namespaces

2011-09-16 Thread Brian Hurt
On Fri, Sep 16, 2011 at 4:01 PM, Stuart Sierra the.stuart.sie...@gmail.comwrote: On Friday, September 16, 2011 3:12:49 PM UTC-4, Brian Hurt wrote: How *should* I structure this code for testing? I was assuming the natural way to do this is to make A, B, and C separate name spaces but maybe

Re: Mocking out namespaces

2011-09-16 Thread Stuart Sierra
Brian Marick wrote Midje to support Clojure testing with a lot of mocking. May be worth a try: https://github.com/marick/Midje -S -- 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

Re: Mocking out namespaces

2011-09-15 Thread Chris Perkins
On Wednesday, September 14, 2011 11:19:13 AM UTC-4, Brian Hurt wrote: Say I have two name spaces, A and B, with A depending on B. I want to test namespace A, replacing module B with a mock B for testing purposes- preferably without having to load B at all (B sucks in a bunch of stuff,

Mocking out namespaces

2011-09-14 Thread Brian Hurt
Say I have two name spaces, A and B, with A depending on B. I want to test namespace A, replacing module B with a mock B for testing purposes- preferably without having to load B at all (B sucks in a bunch of stuff, like dependencies on databases and external web sites and etc. that I don't want

Re: Mocking out namespaces

2011-09-14 Thread Jonathan Fischer Friberg
You could call the mock file B_mock.clj then (require '[B-mock :as B]) Jonathan On Wed, Sep 14, 2011 at 5:19 PM, Brian Hurt bhur...@gmail.com wrote: Say I have two name spaces, A and B, with A depending on B. I want to test namespace A, replacing module B with a mock B for testing purposes-

Re: Mocking out namespaces

2011-09-14 Thread Stuart Sierra
You can't easily prevent the loading of B unless it's in a separate directory that isn't part of your classpath during testing. You could define B-mock to load B and then redefine all the symbols. -S -- You received this message because you are subscribed to the Google Groups Clojure group.

Mocking framework

2011-06-28 Thread Erik Bakstad
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

Re: Mocking framework

2011-06-28 Thread Ola Ellnestam
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

Re: Mocking framework

2011-06-28 Thread gaz jones
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

Re: Mocking framework

2011-06-28 Thread László Török
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

Re: Mocking framework

2011-06-28 Thread Brian Marick
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

Re: Mocking multimethods

2010-12-22 Thread Meikel Brandmeyer
Hi, maybe a different approach could be to use a richer datatype than a function, which carries both: the command and the undo command. (deftype Command [action undo]) Then you could do something like: (defn do-patch! [command args] (dosync (let [patch {:command command :args (vec

Re: Mocking multimethods

2010-12-22 Thread Brian Marick
I think I misunderstand the issue, because this works for me: (ns midje.util.git (:use [midje.sweet])) ;; Code except for undo-patch is the same as before. ;; ... ;; I pulled remove-patch out of undo-patch because I was ;; getting a screwy read error I didn't want to figure out ;; at 5 in

Re: Mocking multimethods

2010-12-22 Thread Alyssa Kwan
I'd like to discuss this design approach. (It's unrelated to the testing issue.) I avoided this design because the undo-fn is determined at do-patch! time. The use case is for a persistent system like Git where patches may be undone long after being done - e.g. long after the patch is written

Re: Mocking multimethods

2010-12-22 Thread Alyssa Kwan
The issue is where do I specify that: (undo-fn ...patch...) = (fn [] (reset! visible-evidence-of-a-side- effect :happened!)) undo-fn is a multimethod in my design, which requires a corresponding defmethod for each patch type. I need to create one for the scope of the test, but defmethod by

Re: Mocking multimethods

2010-12-22 Thread Brian Marick
On Dec 22, 2010, at 6:52 AM, Alyssa Kwan wrote: The issue is where do I specify that: (undo-fn ...patch...) = (fn [] (reset! visible-evidence-of-a-side- effect :happened!)) The code you quoted is that specification. It doesn't matter that undo-fn is a multimethod. Here's what the notation

Re: Mocking multimethods

2010-12-22 Thread Alyssa Kwan
Thanks, Brian! I obviously didn't understand the nature of the provided form. That's really cool notation! This is exactly what I want. What are the cons of using midje? Any reason I shouldn't migrate all my unit testing to it? Thanks! Alyssa On Dec 22, 9:46 am, Brian Marick

Re: Mocking multimethods

2010-12-22 Thread Alex Baranosky
I love Midje and think migrating all the tests to it is a great idea. -- 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

Re: Mocking multimethods

2010-12-22 Thread Brian Marick
What are the cons of using midje? Any reason I shouldn't migrate all my unit testing to it? I'm biased, but I think Midje is ready for production use. There's a smooth migration path because Midje uses the same reporting as clojure.test, so you can mix styles in the same file and still use

Mocking multimethods

2010-12-21 Thread Alyssa Kwan
Hi everyone, Does anyone have any experience in mocking multimethods? I'm working on a version control framework modeled after Git: (def ^{:private true} patches- (ref []) (defn patches [] (seq @patches-)) (defn do-patch! [fn args] (dosync (apply fn args) (let [patch {:fn fn

Re: Mocking multimethods

2010-12-21 Thread Alex Baranosky
Hi Alyssa, Using the midje library I was able to do your first test. I'm pretty tired so I this might be it for the night. (fact throws an error if can't resolve undo function (undo-patch [2]) = (throws IllegalArgumentException No method in multimethod 'undo-fn' for dispatch value: null)) Is

Re: Mocking multimethods

2010-12-21 Thread Alex Baranosky
So I lied, I couldn't resist doing just one more: (defn some-fn [] nil) (fact calls the anonymous function that undo-fn returns (undo-patch ...patch...) = @patches- (provided (undo-fn ...patch...) = some-fn (some-fn) = nil)) The two provided statements are mboth mocking and stubbing

Re: Mocking a namespace?

2010-01-05 Thread Brian Hurt
A better solution that looks like it works is this: load the mock module second. Say I have a module I want to mock: (ns tomock) (defn foo [] 4) and a module that requires it: (ns totest (:require tomock)) (defn bar [] (tomock/foo)) So if I create the file mock_tomock.clj which contains:

Mocking a namespace?

2010-01-04 Thread Brian Hurt
What I'd like to do is mock a full name-space for the purpose of testing other functions that use or require the original name-space. Do people have ideas or best practices for how I can do this? The problem comes in that I very much prefer doing my uses/requires in the name space declaration.

Re: Mocking a namespace?

2010-01-04 Thread .Bill Smith
Brian, I don't blame you -- I wouldn't want to put conditional requires in my code either. Did you consider putting your mock code in a different classpath? Here is another idea. It's tempting to suggest that you write your own version of ns that mucks with its arguments and then passes the

Re: Mocking (with EasyMock?) java calls

2009-11-15 Thread ronen
Id recommend using mockito instead: http://mockito.org/ On Nov 12, 1:55 am, Howard Lewis Ship hls...@gmail.com wrote: Try looking at this: http://github.com/hlship/cascade/blob/master/src/main/clojure/cascade... On Thu, Nov 5, 2009 at 5:00 AM, vanallan vanal...@gmail.com wrote: Hi Im

Re: Mocking (with EasyMock?) java calls

2009-11-11 Thread Howard Lewis Ship
Try looking at this: http://github.com/hlship/cascade/blob/master/src/main/clojure/cascade/mock.clj On Thu, Nov 5, 2009 at 5:00 AM, vanallan vanal...@gmail.com wrote: Hi Im trying to convert a couple of Java methods in a Java project to Clojure. The Java methods have test methods that mocks

Re: Mocking?

2009-09-29 Thread John Harrop
On Mon, Sep 28, 2009 at 9:20 AM, Laurent PETIT laurent.pe...@gmail.comwrote: 2009/9/28 C. Florian Ebeling florian.ebel...@gmail.com In Java I'd just have an interface with two implementations, and bootstrap the tests with a different implementation, in clojure I guess I'd do something

Re: Mocking?

2009-09-29 Thread Mark Derricutt
Sadly, even thou my application isn't all that smart I've already fallen into that trap - as my test first launches a Jetty process running a compojure app, and fires http calls at it - with the send-sms call being behind compojure on another thread. I'm thinking a different way of handling

Re: Mocking?

2009-09-28 Thread Mark Derricutt
From what I've seen of fixtures that just provides setup/teardown functionality (unless I'm mistaken). In my particular instance, I'm wanting to stub out a function defined elsewhere. The function wraps an SMS sending service so I really won't want to get text messages when running tests. In

Re: Mocking?

2009-09-28 Thread C. Florian Ebeling
a dynamic rebinding. This is what you can use: (binding [existing-function (fn [a b] ...)] ;; your tests here ) For mocking java interfaces and classes I'm quite happy with Mockito [1], even though it's usage doesn't look always intuitive in clojure. This is an example for mock-testing a hadoop

Re: Mocking?

2009-09-28 Thread Mark Derricutt
That doesn't to work for me here: (defn disable-bulletin [f] (info Mocking out Bulletin Connect SMS API) (binding [com.jobsheet.util.bulletin/send-sms (fn [a b] (info Sending mock SMS))] (f))) (use-fixtures :once disable-bulletin) I even tried declaring the disable-bulletin

Re: Mocking?

2009-09-28 Thread Stuart Sierra
On Sep 27, 9:18 pm, John Harrop jharrop...@gmail.com wrote: Isn't (binding [foo bar] ...) already such a mechanism? Or does the fixtures feature let you specify such a binding for a whole group of tests obviating the need to repeat the binding form in multiple test functions, Yes. A fixture

Re: Mocking?

2009-09-28 Thread Laurent PETIT
in a separate thread), just using dynamic binding in tests may not be enough, still the binding will not be seen by default by other threads. For mocking java interfaces and classes I'm quite happy with Mockito [1], even though it's usage doesn't look always intuitive in clojure. This is an example

Re: Mocking?

2009-09-28 Thread Matt Clark
This is exactly the sort of purpose I wrote c.c.mock for. It is essentially a glorified binding, but it should fit the bill. (expect [sms-func (times once (has-args [message recipient]))] (code-under-test)) This can tie into clojure.test as well if you are using that. On Sep 28, 3:50 am,

Re: Mocking?

2009-09-27 Thread J. McConnell
On Sun, Sep 27, 2009 at 12:55 AM, Mark Derricutt m...@talios.com 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

Re: Mocking?

2009-09-27 Thread Howard Lewis Ship
wrote: On Sun, Sep 27, 2009 at 12:55 AM, Mark Derricutt m...@talios.com 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

Re: Mocking?

2009-09-27 Thread Stuart Sierra
On Sep 27, 12:55 am, Mark Derricutt m...@talios.com wrote: How are people handling mocking/stubbing in clojure?  Google finds me some old posts about a called? function/macro as part of test-is which looks like it'd do what I need but I can't seem to find any trace of it under clojure/clojure

Re: Mocking?

2009-09-27 Thread John Harrop
On Sun, Sep 27, 2009 at 8:06 PM, Stuart Sierra the.stuart.sie...@gmail.comwrote: On Sep 27, 12:55 am, Mark Derricutt m...@talios.com wrote: How are people handling mocking/stubbing in clojure? Google finds me some old posts about a called? function/macro as part of test-is which looks

Mocking?

2009-09-26 Thread Mark Derricutt
'lo all, How are people handling mocking/stubbing in clojure? Google finds me some old posts about a called? function/macro as part of test-is which looks like it'd do what I need but I can't seem to find any trace of it under clojure/clojure-contrib trunk. Any pointers? -- Pull me down under

Re: [ANN] test-expect functional mocking/expectation library

2009-06-10 Thread Stuart Halloway
... When I started working on this library, I thought to myself, I can't believe no one has put together an expectation/mocking library but I couldn't find one so I went ahead and started my own. Of course, it was not until I had an early working version that I discovered Allen Rohner's

Re: [ANN] test-expect functional mocking/expectation library

2009-06-10 Thread Stuart Halloway
for writing this! Stu When I started working on this library, I thought to myself, I can't believe no one has put together an expectation/mocking library but I couldn't find one so I went ahead and started my own. Of course, it was not until I had an early working version that I discovered

Re: test-expect functional mocking/expectation library

2009-06-10 Thread Matt Clark
thought to myself, I can't believe no one has put together an expectation/mocking library but I couldn't find one so I went ahead and started my own.  Of course, it was not until I had an early working version that I discovered Allen Rohner's expectation tools, but I figured that mine were

Re: test-expect functional mocking/expectation library

2009-04-13 Thread Allen Rohner
Of course, it was not until I had an early working version that I discovered Allen Rohner's expectation tools, but I figured that mine were sufficiently different to merit further development (at least relative to the latest code of his I could find). Suggestions for further changes or

[ANN] test-expect functional mocking/expectation library

2009-04-11 Thread Matt Clark
When I started working on this library, I thought to myself, I can't believe no one has put together an expectation/mocking library but I couldn't find one so I went ahead and started my own. Of course, it was not until I had an early working version that I discovered Allen Rohner's expectation

Re: mocking in clojure

2009-03-16 Thread Allen Rohner
On Mar 13, 3:35 pm, Stephen C. Gilardi squee...@mac.com wrote: On Mar 13, 2009, at 4:10 PM, Stuart Sierra wrote: Hi Allen, Sorry I haven't kept up with this. I think, though, that it's best to have it as a standalone library in clojure-contrib, so that people can use it with other

mocking in clojure

2009-03-13 Thread Korny Sietsma
Hi folks - are there any frameworks out there for mocking? Stubbing functions is pretty straightforward (and I see that fact comes with a stubbing function built in), but I'd really like something that can do mocking and mock expectations - something similar to stub, but with checking

Re: mocking in clojure

2009-03-13 Thread Matt Clark
, 7:39 am, Korny Sietsma ko...@sietsma.com wrote: Hi folks - are there any frameworks out there for mocking? Stubbing functions is pretty straightforward (and I see that fact comes with a stubbing function built in), but I'd really like something that can do mocking and mock expectations

Re: mocking in clojure

2009-03-13 Thread Allen Rohner
Any other options out there? I posted a patch for test-is a while ago that never made it in, and I don't know why. http://groups.google.com/group/clojure/browse_frm/thread/883d4833f869f764/47a45325c8f29599?lnk=gstq=test-is+expect+patch#47a45325c8f29599 The patch handles creating stub

Re: mocking in clojure

2009-03-13 Thread Stuart Sierra
Hi Allen, Sorry I haven't kept up with this. I think, though, that it's best to have it as a standalone library in clojure-contrib, so that people can use it with other testing frameworks if they want to. -Stuart On Mar 13, 3:20 pm, Allen Rohner aroh...@gmail.com wrote: Any other options out

Re: mocking in clojure

2009-03-13 Thread Stephen C. Gilardi
On Mar 13, 2009, at 4:10 PM, Stuart Sierra wrote: Hi Allen, Sorry I haven't kept up with this. I think, though, that it's best to have it as a standalone library in clojure-contrib, so that people can use it with other testing frameworks if they want to. -Stuart Allen, I see you have a