Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Test by

I think several times I have done something similar to

(is (= some-map (try (func ...) (catch Exception e (ex-data e)))

Not sure if this had been asked before but would there be any interest in some form of

(defmethod assert-expr 'thrown-with-data? [x form]

that would check the data map of an exception?

One complication is that strings have any easy vehicle for partial matching: the regex. Maps have no ubiquitous matcher like this, leading to no obvious input. Options could be a single arg function that would receive the map and return true or false similar to the regex. Or maybe just allow for a value to compare against? Perhaps a spec?

Obviously lots of design choices here and not sure if that means leave it to individual users or if there was room or interest in clojure.test.

1 Answer

+1 vote
by

Definitely interested if there’s something that makes sense. Would be interested if people have created things like this already if there’s any experience.

...