What is the proper way to do the following in clojure?
(ns todo.test.models.task
(:use [clojure.test]))
(deftest main-test
(is (thrown? Exception (throw Exception "stuff")))
(is (not (thrown? Exception (+ 2 3))))
)
First testcase runs fine but the whole snippet returns "Unable to resolve symbol: thrown?"
is
is a macro that looks for the symbol thrown?
in its body and build tests.
thrown?
is not actually a function you can call. The default behaviour of is
fails the test if an exception is thrown that was not beeing looked for, so you can just remove the (not (thrown?
from the above example and get the result you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With