@olfal I think with-redefs
is the usual approach.
I don't know Midje, but it might be that provided
can be used for this: https://github.com/marick/Midje/wiki/Prerequisites-that-throw-exceptions
However, I personally prefer expectations - but I don't think there's any built in support for mocking functions to make them throw exceptions.
Thanks @jumar! Midje looks great, I will try it out
@olfal you may also like clj-fakes
: https://github.com/metametadata/clj-fakes
(f/with-fakes
(f/patch! #'funcs/sum (f/fake [[5 6] (fn [_ _] (throw (ex-info "wow" {})))]))
(funcs/sum 5 6)) ; => raises "wow" exception