我正在尝试为我的:pre
和:post
条件编写单元测试,我的第一个想法是这样的:
(ns myproj.battle-test
(:use clojure.test
myproj.battle))
(deftest lose-only-positive-amount-of-health
(let [actor {:health 100}]
(is (thrown? AssertionException
(:health (lose-health actor -5))))))
但我不知道如何从我的测试文件中引用AssertionException
,并获得一个异常:
java.lang.IllegalArgumentException: Unable to resolve classname: AssertionException
我尝试了各种方法(Google并没有提供有用的信息,可能是因为这个问题太简单了),但没有任何运气,那么我该如何检查是否抛出了
AssertionException
?我意识到这非常适合初学者的问题;这是我在Clojure中的前几行 :)