testing

Testing tools, testing philosophy & methodology...
jumar 2017-03-22T08:18:37.545762Z

@olfal I think with-redefs is the usual approach.

jumar 2017-03-22T08:18:50.548421Z

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

jumar 2017-03-22T08:20:41.572725Z

However, I personally prefer expectations - but I don't think there's any built in support for mocking functions to make them throw exceptions.

olfal 2017-03-22T12:53:26.895751Z

Thanks @jumar! Midje looks great, I will try it out

metametadata 2017-03-22T17:44:21.213723Z

@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

👍 1