【发布时间】:2016-10-08 07:53:06
【问题描述】:
我的源代码中有一个简单的函数hello。
(defn hello [n] (str "Hello" n))
在测试用例中,我调用了hello 函数。但似乎它正在返回nil。测试用例:
(deftest test (testing "string"
;(is (= "Hello x" (ql/hello "x")))))
(is (= (ql/hello "x") "Hello x"))))
我收到以下错误。
expected: (= (ql/hello "x") "Hello x")
actual: (not (= nil "Hello x"))
为什么返回nil?如果我从 repl 调用 hello 函数,我会得到“Hello x”,然后是 nil,但我认为这是由于 repl 造成的,对吧?当我从另一个函数调用hello 时,它不应该返回字符串吗?我直接从 repl 运行测试用例,而不是使用 lein。
【问题讨论】:
-
我在repl中没有得到
nil。
标签: unit-testing clojure assertions