我创建了一个新的 Clojurescript/Om 项目。目录结构如下所示:
├── 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
我的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"])
但是,我无法让 Leiningen 识别测试路径。当我运行 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.
我将测试从 test/clj/example-project/...
移至 test/example-project/...
,并将实现从 >src/clj/example-project/
到 src/example-project
但我仍然看到相同的错误。
如何让 Leiningen 认可我的测试?
最佳答案
也许 :test-paths
需要更进一步,以便 lein 可以找到源代码。
你可以尝试:
:test-paths ["test/clj"]
我发现您使用基本相同的思维来移动源代码。但这更容易。此外,在对 project.clj
进行任何更改后,您需要lein clean
,然后lein deps
。我的方式更多地关注deps
,而你的方式更多地关注clean
,但无论如何都是权宜之计。此外,您还需要检查 clean
是否确实删除了输出。如果不是,您可以随时通过删除文件来手动清理。
关于clojure - 更改 Clojure/Leiningen 项目中的测试目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36579953/