[英]Changing the test directory in a Clojure/Leiningen project
I created a new Clojurescript/Om project. 我创建了一个新的Clojurescript / Om项目。 The directory structure looks like this: 目录结构如下所示:
├── project.clj
├── resources
│ └── public
│ ├── index.html
│ └── src
│ └── om_tutorial
│ └── core.cljs
├── script
│ └── figwheel.clj
├── src
│ ├── clj
│ │ ├── test
│ │ └── example-project
│ │ └── core.clj
│ └── cljs
│ └── example-project
│ └── core.cljs
├── target
│ ├── classes
│ │ └── META-INF
│ │ └── maven
│ │ └── typing
│ │ └── typing
│ │ └── pom.properties
│ └── stale
│ └── leiningen.core.classpath.extract-native-dependencies
└── test
└── clj
└── example-project
└── test_core.clj
My package.json
is very minimal, and it looks like this: 我的package.json
非常小,看起来像这样:
(defproject typing "0.1.0-SNAPSHOT"
:description "example-project"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[org.omcljs/om "1.0.0-alpha22"]
[figwheel-sidecar "0.5.0-SNAPSHOT" :scope "test"]
[http-kit "2.2.0-SNAPSHOT"]
[compojure "1.5.0"]
[ring "1.4.0"]
[cheshire "5.5.0"]]
:test-paths ["test"])
However, I can't get Leiningen to recognize the test path. 但是,我无法让Leiningen认识到测试路径。 When I run lein test
, I see: 当我运行lein test
,我看到:
Exception in thread "main" java.io.FileNotFoundException: Could not locate test/typing/test_core__init.class or test/example-project/test_core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name., compiling:(/private/var/folders/dk/jvt798yj6ds6wnkwk_24wrcm0000gp/T/form-init5157365051258208935.clj:1:125)
...
Caused by: java.io.FileNotFoundException: Could not locate test/example-project/test_core__init.class or test/example-project/test_core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
...
Tests failed.
I moved the tests from test/clj/example-project/...
to test/example-project/...
, and the implementation from src/clj/example-project/
to src/example-project
but I still see the same error. 我将测试从test/clj/example-project/...
到test/example-project/...
,以及从src/clj/example-project/
到src/example-project
但我仍然看到同样的错误。
How do I get Leiningen to recognize my tests? 如何让Leiningen识别我的测试?
Perhaps the :test-paths
need to reach in further so that source code can be found by lein. 也许:test-paths
需要进一步扩展,以便lein可以找到源代码。
You could try: 你可以尝试:
:test-paths ["test/clj"]
I see you moved source code around using basically the same thinking. 我看到你使用基本相同的思想来移动源代码。 But this is easier. 但这更容易。 Also after any changes to project.clj
you need to lein clean
then lein deps
. 在对project.clj
进行任何更改之后,你需要lein clean
然后lein deps
。 My way is more about the deps
and yours more about the clean
, but both regardless is expedient. 我的方式更多的是关于deps
和你的更多关于clean
,但两者都是权宜之计。 Also you need to check that clean
is actually getting rid of output. 此外,你需要检查clean
实际上是摆脱输出。 If it is not you can always manually clean by deleting files. 如果不是,您可以通过删除文件来手动清理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.