I'm brand new to Clojure, and I am having a bit of trouble getting unit tests running.
(ns com.bluepojo.scratch
(:require clojure.test))
(defn add-one
([x] (+ x 1))
)
(is (= (add-one 3) 4))
gives:
java.lang.Exception: Unable to resolve symbol: is in this context
What am I missing?
Update:
This works:
(clojure.test/is (= (add-one 3) 4))
How do I make it so that I don't have to declare clojure.test before the is?
Your use of the ns macro is not quite correct and you have several options to fix it. I would suggest one of
clojure.test
to something shorter(ns com.bluepojo.scratch
(:require [clojure.test :as test))
(defn add-one
([x] (+ x 1)))
(test/is (= (add-one 3) 4))
use
(ns com.bluepojo.scratch
(:use [clojure.test :only [is]]))
(defn add-one
([x] (+ x 1)))
(is (= (add-one 3) 4))
Take a look at this article which explains this at some length
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