【问题标题】:I cannot run tests in clojure/midje我无法在 clojure/midje 中运行测试
【发布时间】:2013-04-29 12:46:57
【问题描述】:

我运行测试:

lein midje :autotest

我得到错误:

线程“main”java.lang.Exception 中的异常:没有命名空间: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 找到

测试在: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

【问题讨论】:

    标签: import clojure namespaces midje


    【解决方案1】:

    您的一个命名空间中有一个编译错误,我怀疑 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))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多