Testing 如何在测试中抛出此异常?
我试图测试一个Testing 如何在测试中抛出此异常?,testing,exception,clojure,Testing,Exception,Clojure,我试图测试一个java.sql.SQLException处理程序,该处理程序如下所示打开异常。但是,我不确定如何在测试中抛出此异常 (-> e (.getNextException) (.getMessage) (.startsWith "ERROR: duplicate key value")) 当前模拟(.getNextException)在以下情况下返回nil: (throw (SQLException. "ERROR: duplicate key
java.sql.SQLException
处理程序,该处理程序如下所示打开异常。但是,我不确定如何在测试中抛出此异常
(-> e
(.getNextException)
(.getMessage)
(.startsWith "ERROR: duplicate key value"))
当前模拟(.getNextException)
在以下情况下返回nil:
(throw (SQLException. "ERROR: duplicate key value"))
你想要:
(throw (doto (SQLException. "Top-level exception")
(.setNextException (SQLException. "ERROR: duplicate key value"))))
请将您的代码添加到问题中。