这有助于定义一个辅助函数,例如
(defn speccheck [fn-to-check options]
(let [results (t/check [fn-to-check] options)]
(if (some :failure results)
(do
(println "\nFailed specs:")
(doseq [result results
:when (:failure result)]
(println (:sym result))
(pprint (or (ex-data (:failure result))
(:failure result)))))
true)))
(deftest my-fun-test
(is (speccheck `this/is-my-fn {}))) ; pass options to t/check as needed
这有助于在失败的情况下,因为您希望打印失败的消息。