Search code examples
clojurecode-coveragespeclj

cloverage FileNotFoundException


I would like to use cloverage so I can check how much of my code base is tested by speclj. However after installing cloverage as a lein plugin and running: lein cloverage I see the following exception:

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.

I've not used cloverage before so what to check if I'm using it correctly, has anyone come across this issue before?

This is what my project.clj looks like:

(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"]
                                      ]
                       }
             }
  )

spec/app/component/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...
    )

Solution

  • Your problem is probably unrelated to Cloverage specifically. It looks like you're trying to require app.unit.core-spec, and that file either doesn't exist or hasn't been properly named (don't forget source files should have underscores, not dashes!)