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, 
> like dependencies on databases and external web sites and etc. that I don't 
> want to deal with in testing).  What is the easy, clojure-approved, 
> mechanism for doing this?  I tried:
>
>
>
my-project
  |-- src
  |     |-- A.clj
  |     |-- B.clj
  | -- mocks
  |     |-- B.clj
  |-- testdriver.clj

# Run with the real B:
java -cp clojure.jar:src clojure.main testdriver.clj

# Run with the mock B:
java -cp clojure.jar:mocks:src clojure.main testdriver.clj

I don't know if my ascii-art directory tree makes any sense at all, but the 
point is that if you put "mocks" earlier in the classpath than "src", then 
the mock B should get loaded instead of the real one.

- Chris

-- 
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

Reply via email to