Created
May 14, 2010 19:27
-
-
Save dakrone/401546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro mock-2 | |
[class method arglist result] | |
(let [mocked (gensym class)] | |
`(let [~mocked (org.mockito.Mockito/mock ~class)] | |
~(list '.thenReturn | |
(list 'org.mockito.Mockito/when | |
(list* (symbol (str \. method)) mocked arglist)) | |
result)))) | |
user=> (macroexpand-1 '(mock-2 File myMethod ["foo" "foo"] "bar")) | |
(clojure.core/let | |
[File2567 (org.mockito.Mockito/mock File)] | |
(.thenReturn (org.mockito.Mockito/when (.myMethod File2567 "foo" "foo")) "bar")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment