amitrathore / conjure

a mocking library for clojure
http://s-expressions.com
73 stars 9 forks source link

Cannot mock/stub private functions #15

Open olfal opened 6 years ago

olfal commented 6 years ago

It would be nice to allow mocking/stubbing of private functions, for some particular use cases. The with-redefs function already allows this and a workaround is possible, but I'd rather not mix mocks and redefs.

Workaround :

(defn public-my-function [])

(deftest each-statement-is-executed
  (mocking [public-my-function]
           (with-redefs [my-private-function public-my-function]
             (a-fonction-calling-my-private-function)
             (verify-call-times-for public-my-function 420))))