运行 Midje 测试时出现 FileNotFound 异常

FileNotFound exception while running Midje tests

我有一个使用 Midje 库进行测试的 Leiningen 项目。但是我无法 运行 任何测试,以防 lein test 我得到

java.io.FileNotFoundException: Could not locate midje/sweet__init.class or midje/sweet.clj on classpath

或者 lein midje test 我得到

java.io.FileNotFoundException: Could not locate midje/util/ecosystem__init.class or midje/util/ecosystem.clj on classpath

所以我想这是因为我错误地定义了 dev 具有依赖关系的配置文件,但我不确定真正的问题出在哪里。

作为奖励,我也无法让 environ 工作,我总是得到 nil,我想从 env 地图中拉出一些 属性(这可能也是同样的问题)。

我的project.clj

(defproject
  project
  "0.1.0-SNAPSHOT"
  :dependencies
   [[org.clojure/clojure "1.8.0"]
   [environ "1.1.0"]
   ;; other deps, midje is not there
   :repl-options
      {:init-ns mailing.repl}
   :jvm-opts
      ["-server"]
   :plugins
      [[lein-ring "0.8.13"]
       [lein-environ "1.0.0"]
       [lein-ancient "0.5.5"]
       [migratus-lein "0.4.2"]] 
   :ring
     {:handler mailing.handler/app,
   :init mailing.handler/init,
   :destroy mailing.handler/destroy}
   :profiles
      {:uberjar {:omit-source true, :env {:production true}, :aot :all},
       :production
      {:ring {:open-browser? false, :stacktraces? false, :auto-reload? false}},
      {:dev
        {:env 
          {:db-user "user" 
           :db-password "psswd"
           :db-classname "org.postgresql.Driver"
           :db-subprotocol "postgresql"
           :db-subname "//localhost/mailer"}}}
      {:dependencies
[[ring-mock "0.1.5"]
 [ring/ring-devel "1.3.1"]
 [midje "1.6.3"]],
:env {:dev true}}}
  :migratus {
         :store :database
         :migration-dir "migrations"
         :db {
              :classname "org.postgresql.Driver"
              :subprotocol "postgresql"
              :subname "//localhost/mailer"
              :user "usr"
              :password "psswd"}}
;; refer to user and psswd from project
:min-lein-version "2.0.0")

我没试过,但结构似乎不太正确。我认为它应该是这样的:

(defproject project "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [environ "1.1.0"]]
  ;; other deps, midje is not there
  :repl-options {:init-ns mailing.repl}
  :jvm-opts ["-server"]
  :plugins [[lein-ring "0.8.13"]
            [lein-environ "1.0.0"]
            [lein-ancient "0.5.5"]
            [migratus-lein "0.4.2"]]
  :ring {:handler mailing.handler/app
         :init mailing.handler/init
         :destroy mailing.handler/destroy}
  :profiles {:uberjar {:omit-source true
                       :env {:production true}
                       :aot :all}
             :production {:ring {:open-browser? false
                                 :stacktraces? false
                                 :auto-reload? false}}
             :dev {:env {:db-user "user"
                         :db-password "psswd"
                         :db-classname "org.postgresql.Driver"
                         :db-subprotocol "postgresql"
                         :db-subname "//localhost/mailer"
                         :dev true}
                   :dependencies [[ring-mock "0.1.5"]
                                  [ring/ring-devel "1.3.1"]
                                  [midje "1.6.3"]]}}
  :migratus {:store :database
             :migration-dir "migrations"
             :db {:classname "org.postgresql.Driver"
                  :subprotocol "postgresql"
                  :subname "//localhost/mailer"
                  :user "usr"
                  :password "psswd"}}

   ;; refer to user and psswd from project
   :min-lein-version "2.0.0")

看起来您靠近顶部的 :dependecies 块格式不正确(没有关闭 ]),并且开发依赖项实际上并未与 :dev 配置文件相关联。我不确定 :migratus 是否属于 :dev 配置文件,因此在上面的示例中它不在其中。

FWIW,Leiningen 存储库中的 sample project 文件是有用的资源。