Lein Midje:自动测试抛出异常(未找到命名空间)

时间:2013-10-25 12:24:25

标签: clojure leiningen midje

我正在尝试为midje设置自动测试。目前,正在运行lein midje的工作。但是运行lein midje:autottest会给我下面的堆栈跟踪。

我运行不同的命名空间,它们都编译

Compiling 1 source files to /Users/oloo/Documents/work/cmp/target/classes

warning: Supported source version 'RELEASE_6' from annotation processor 'org.sonatype.guice.bean.scanners.index.SisuIndexAPT6' less than -source '1.7'
1 warning

======================================================================
Loading (cmp.models cmp.util cmp.repository.orderdeliveryschedule-repository cmp.repository.facility-repository cmp.repository.facility-cycle-data-repository cmp.views.layout cmp.routes.facility cmp.repository.item-repository cmp.repository.procurement-plan-repository cmp.routes.login cmp.excel-util cmp.repository.district-repository cmp.repository.facility-order-repository cmp.repository.facility-issue-repository cmp.routes.import-data cmp.test-util cmp.routes.item cmp.routes.district cmp.repository.user-repository cmp.routes.reports cmp.repository.category-repository cmp.routes.facility-issue cmp.routes.procurement-plan cmp.routes.facility-order cmp.handler cmp.repl cmp.repository.level-repository)
log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.Exception: No namespace: cmp.routes.item found
    at clojure.core$the_ns.invoke(core.clj:3760) 
    at clojure.core$ns_name.invoke(core.clj:3767)  
    at midje.repl$on_require_failure.invoke(repl.clj:387)  
    at midje.data.project_state$require_namespaces_BANG_$broken_source_file_QMARK___5874.invoke(project_state.clj:65)  
    at midje.data.project_state$require_namespaces_BANG_$shorten_ns_list_by_trying_first__5877.invoke(project_state.clj:69)  
    at midje.data.project_state$require_namespaces_BANG_.invoke(project_state.clj:75)  
    at midje.data.project_state$react_to_tracker_BANG_$fn__5889.invoke(project_state.clj:98)  
    at midje.repl$namespace_stream_checker.invoke(repl.clj:403)  
    at midje.data.project_state$react_to_tracker_BANG_.invoke(project_state.clj:94)  
    at midje.data.project_state$mkfn_COLON_scan_and_react$fn__5893$fn__5894.invoke(project_state.clj:109)  
    at clojure.lang.Atom.swap(Atom.java:37)  
    at clojure.core$swap_BANG_.invoke(core.clj:2160)  
    at midje.data.project_state$mkfn_COLON_scan_and_react$fn__5893.invoke(project_state.clj:107)  
    at midje.data.project_state$load_everything.invoke(project_state.clj:117)  
    at midje.repl$autotest.doInvoke(repl.clj:511)  
    at clojure.lang.RestFn.invoke(RestFn.java:397)  
    at midje.repl$autotest.doInvoke(repl.clj:524)  
    at clojure.lang.RestFn.invoke(RestFn.java:408)  
    at user$eval6032.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6619)  
    at clojure.lang.Compiler.eval(Compiler.java:6609)  
    at clojure.lang.Compiler.eval(Compiler.java:6582)  
    at clojure.core$eval.invoke(core.clj:2852)  
    at clojure.main$eval_opt.invoke(main.clj:308)  
    at clojure.main$initialize.invoke(main.clj:327)  
    at clojure.main$null_opt.invoke(main.clj:362)  
    at clojure.main$main.doInvoke(main.clj:440)  
    at clojure.lang.RestFn.invoke(RestFn.java:421)  
    at clojure.lang.Var.invoke(Var.java:419)  
    at clojure.lang.AFn.applyToHelper(AFn.java:163)  
    at clojure.lang.Var.applyTo(Var.java:532)  
    at clojure.main.main(main.java:37)  
Subprocess failed

2 个答案:

答案 0 :(得分:3)

请参阅:https://github.com/marick/Midje/issues/215

它说:

If a file being loaded by Midje at startup has a parse error (a reference to an unknown 
symbol, etc.) that prevents it from being loaded successfully, Midje swallows the original
load error and instead prints the following error, which is much less useful.

我也受此影响:任何小错字都会引发这种误导性错误信息。

答案 1 :(得分:2)

我记得使用:require表单的:use[prefix ns1 ns2 ...]其他命名空间的自动测试和命名空间存在问题。所以,以下不起作用:

(ns abc
  (:use [abc def ghi]))

虽然这没关系:

(ns abc
  (:use abc.def
        abc.ghi))

您使用的是这种语法吗?