我们如何在clojure中编写测试用例来测试(Exception. "MyCustomException")
我试过(is (thrown? (Exception. "MyCustomException") (method-name param)))
但这不起作用。
PS:我是clojure的新手
答案 0 :(得分:1)
使用实例?检查是否派生Exception类型的方法=> http://clojuredocs.org/clojure.core/instance_q
(defrecord ExampleExceptionClass [x])
(try
;; do something here
(catch Exception ex
(instance? ExampleExceptionClass ex)))