我无法在clojure/midje中运行测试



我使用:

运行测试
lein midje :autotest

得到error:

main线程异常java.lang.Exception: No namespace: sprint-is。json-export发现

文件位于:sprint-is/src/sprint_is/json_export.clj

包含代码:

(ns sprint-is.json-export)
(require [[noir.response :as response]])
(defn serialize [value] (response/json value))

它抛出这个错误,即使我没有测试文件。当我创建测试文件,我得到类似的错误:

没有命名空间:sprint-is.test。json-export发现

Test is in: sprint-is/Test/sprint_is/json_export.clj

,包含:

(ns sprint-is.test.json-export
    (:require [sprint-is.json-export :as json-export]))
(fact "module can serialize scalar values"
    (json-export/serialize 123) => 123)

当我尝试从REPL导入它时,它也找不到名称空间。我试图重命名文件,移动文件,重命名目录,删除ns(它编译,但它不工作),问Clojure IRC。我将代码与其他项目(包括在我的计算机上工作的项目)进行了比较,似乎是相同的。

源代码在这里:https://bitbucket.org/jiriknesl/sprintis

您的一个命名空间有编译错误,我怀疑是sprint-is.json-export

在bitbucket上,你有这个:

(ns sprint-is.json-export)
(require [[noir.response :as response]])
(defn serialize [value] (response/json value))

不能编译,因为noir.responseresponse没有定义。

你应该有:

(ns sprint-is.json-export
   (:require [noir.response :as response]))
(defn serialize [value] (response/json value))

如果您坚持在ns宏之外使用require,则可以执行以下操作,但请注意,这不是惯用的用法。

(ns sprint-is.json-export)
(require '[noir.response :as response])
(defn serialize [value] (response/json value))

最新更新