I'm just getting started in Clojure, and I'm trying to figure out how to run tests using an alias. Here's what my deps.edn
file looks like:
{:paths ["src"]
:aliases {
:test {:extra-paths ["test"]
:main-opts ["-e" "(require 'clacks/core-test) (clojure.test/run-tests 'clacks/core-test)"]}}}
Here's what my directory structure looks like:
.
├── deps.edn
├── src
│ └── clacks
│ └── core.clj
└── test
└── clacks
└── core_test.clj
Here's what my core_test.clj
file looks like:
(ns clacks.core-test
(:require [clojure.test :refer [deftest is testing run-test]]
[clacks.core :refer [alphabet]]))
(deftest alphabet-test
(testing "Testing the alphabet"
(is (map? alphabet) "Not a map!")
(is (seq alphabet))))
(run-test alphabet-test)
And finally, here's the error I'm getting when I try to run clj -M:test
Could not locate core_test__init.class, core_test.clj or core_test.cljc on classpath. Please check that namespaces with dashes Blockquote use underscores in the Clojure file name.
Any idea why this is happening? Any help would be really appreciated. Thanks!
Namespace segments are separated with dots, not slashes - regardless of whether it's in some (ns ...)
form or some other context, like (require ...)
.
So this part
(require 'clacks/core-test) (clojure.test/run-tests 'clacks/core-test)
should be
(require 'clacks.core-test) (clojure.test/run-tests 'clacks.core-test)