I'm just starting to play with Clojure and am having difficulty with something basic. I want to just test a simple function that does 1 + 1.
Here's core.clj
(ns core)
(defn run []
(+ 1 1))
Here's the test, core-test.clj
(ns core-test
(:require [clojure.test :refer :all]
[core :refer :all]))
(deftest a-test
(testing "Core"
(is (= 2 run))))
Here's the result
lein test core-test
lein test :only core-test/a-test
FAIL in (a-test) (core_test.clj:7)
Core
expected: (= 2 run)
actual: (not (= 2 #object[core$run 0x12f8b1d8 "core$run@12f8b1d8"]))
Ran 1 tests containing 1 assertions.
1 failures, 0 errors.
Tests failed.
You are not calling run
. Right now you are comparing 2
with the function. Use (= 2 (run))
.