1

我想使用 cloverage,这样我就可以检查我的代码库中有多少是由 speclj 测试的。但是,在将 cloverage 作为 lein 插件安装并运行后:lein cloverage我看到以下异常:

Exception in thread "main" java.io.FileNotFoundException:
Could not locate app/unit/core_spec__init.class or app/unit/core_spec.clj on classpath.
Please check that namespaces with dashes use underscores in the Clojure file name.,
compiling:(/private/var/folders/w_/yt926bqs21g44f257yz05ctsjbv948/T/form-init4597524674545750330.clj:1:125)

Caused by: java.io.FileNotFoundException: Could not locate app/component/core_spec__init.class or app/component/core_spec.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

我以前没有使用过 cloverage,所以如何检查我是否正确使用它,以前有没有人遇到过这个问题?

这就是我的 project.clj 的样子:

(defproject app version
  :dependencies [
                 [org.clojure/clojure "1.8.0"]
                 [org.clojure/tools.logging "0.4.0"]
                 [org.clojure/tools.cli "0.3.5"]
                 [org.clojure/data.json "0.2.6"]
                 [org.postgresql/postgresql "9.4-1201-jdbc41"]
                 [org.slf4j/slf4j-log4j12 "1.7.25"]
                 [log4j/log4j "1.2.17" :exclusions [javax.mail/mail
                                                    javax.jms/jms
                                                    com.sun.jmdk/jmxtools
                                                    com.sun.jmx/jmxri]]
                 [metosin/compojure-api "1.1.11"]
                 [metosin/ring-swagger "0.24.3"]
                 [compojure "1.6.0"]
                 [cheshire "5.8.0"]
                 [ring "1.6.3"]
                 [ring/ring-json "0.4.0"]
                 [ring-logger "0.7.7"]
                 [environ "1.1.0"]
                 [korma "0.4.3"]
                 [blackwater "0.0.9"]
                 [prismatic/schema "1.1.7"]
                 [siili/humanize "0.1.1"]
                 [amazonica "0.3.117"]
                 ]

  :main app.cli.core
  :plugins [
            [lein-ring "0.12.1"]
            [lein-cloverage "1.0.10"]
            [speclj "3.3.2"]
            ]

  :test-paths ["spec"]

  :profiles {
             :uberjar {:aot :all}

             :user    {
                       :plugins
                       [[cider/cider-nrepl "0.16.0"]
                              [lein-kibit "0.1.6"]
                              [nightlight/lein-nightlight "1.0.0"]
                              [lein-cloverage "1.0.6"]
                              [jonase/eastwood "0.2.3"]
                              [lein-cloverage "1.0.9"]
                        [speclj "3.3.2"]]
                       }

             :dev     {
                       :dependencies [
                                      [ring-mock "0.1.3"]
                                      [clj-http "3.7.0"]
                                      [org.clojure/data.json "0.2.6"]
                                      [speclj "3.3.2"]
                                      [clj-time "0.14.2"]
                                      [listora/again "0.1.0"]
                                      [environ "1.1.0"]
                                      ]
                       }
             }
  )

规范/应用程序/组件/core_spec.clj

(ns app.component.core_spec
  (:require [speclj.core :refer :all]
            [clojure.data.json :as json]
            [clj-http.client :as client]
            [clj-time.core :as t]
            [again.core :as again]
            [clj-time.format :as f]
            [environ.core :refer [env]]))

    (describe "app"
        ; tests and things...
    )
4

1 回答 1

1

您的问题可能与 Cloverage 无关。看起来您正在尝试require app.unit.core-spec,并且该文件不存在或没有正确命名(不要忘记源文件应该有下划线,而不是破折号!)

于 2018-04-11T13:50:51.803 回答