首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行Midje测试时的FileNotFound异常

运行Midje测试时的FileNotFound异常
EN

Stack Overflow用户
提问于 2016-11-11 19:50:01
回答 1查看 261关注 0票数 0

我有一个Leiningen项目,它使用Midje库进行测试。但是,我不能运行任何测试,如果我得到lein test

代码语言:javascript
复制
java.io.FileNotFoundException: Could not locate midje/sweet__init.class or midje/sweet.clj on classpath

或者用lein midje test我得到

代码语言:javascript
复制
java.io.FileNotFoundException: Could not locate midje/util/ecosystem__init.class or midje/util/ecosystem.clj on classpath

因此,我想这是因为我错误地定义了带有依赖项的dev配置文件,但我不知道真正的问题在哪里。

另外,我也不能让environ工作,我总是得到nil,我想从env映射中提取一些属性(这可能也是同样的问题)。

我的project.clj

代码语言:javascript
复制
(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")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-11 20:16:39

我没有试过这个,但是这个结构看上去不太正确。我觉得应该是这样的:

代码语言:javascript
复制
(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回购中的样本工程文件是一个有用的资源。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40555189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档