On Aug 15, 10:16 pm, Kevin Livingston <kevinlivingston.pub...@gmail.com> wrote: > I am working on an api that has an interface and two distinct > implementations lets call them: foo and bar. > > I have a testing routine with a bunch of functions that each call a > function to get a clean instance of an implementation, initializes it > with some data and then interrogate it. > > with the exception of calling (new-foo) or (new-bar), foo and bar can > be tested identically. I would like to be able to define tests in a > namespace for the api, then have a test-foo namespace that calls those > tests with *new-test-instance* bound to new-foo. likewise for new > bar. because I would like the exact same tests run, the whole point > is these things should behave the same at the API level. I don't want > to have to copy and paste all my tests and make sure I keep them > synchronized, that seems like an error waiting to happen. > > I can define the tests in test-api with deftest but doing so will > cause the test to be run there (when I call mvn clojure:test), and as > there is no implementation they will of course fail. I can block test- > api from calling it's tests with: > (defn test-ns-hook []) > but then the tests become a pain to call from another namespace. > > surely there is a way to do this?
(defn test-ns-hook [] (when (bound? #'api-instance) ...))? > in test-api with the blocking test-ns-hook, I tried > (def the-tests [ > (deftest test-1 .... ) ]) > > then in test-foo I tried > > (defn test-ns-hook [] > (dorun > (map (fn [x] > (binding [project.test-api/*new-test-instance* > (fn [] (new-foo))] > (x))) > project.test-api/the-tests))) > > that doesn't work I keep seeing this: > > Uncaught exception, not in assertion. > expected: nil > actual: java.lang.NoClassDefFoundError: org/slf4j/impl/ > StaticLoggerBinder > ... > > except if I put that exact same test-ns-hook implementation into the > repl and call (run-tests) everything checks out *exactly* as expected. > > I have spent way too many hours on this... help? > > Kevin -- 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