简体   繁体   English

更改Clojure / Leiningen项目中的测试目录

[英]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.

相关问题 使用leiningen访问clojure中项目目录外的JSON文件 - Access to JSON files outside project directory in clojure using leiningen 在LightTable中运行leiningen Clojure项目 - Running a leiningen Clojure project in LightTable (clojure测试)配置leiningen在src中运行测试(不仅在测试目录中) - (clojure testing) Configure leiningen to run tests inside src (not only in the test directory) 如何使用 jUnit 测试运行程序在 Intellj 中创建新的 Leiningen Clojure 项目? - How do I create a new Leiningen Clojure project in Intellj using the jUnit test runner? Clojure Leiningen 测试失败未显示在错误摘要中 - Clojure Leiningen test FAILs not shown in error summary 无法使用 Leiningen 使用 Cursive 运行 Clojure 项目 - Can not run Clojure project with Cursive using Leiningen 获取leiningen项目根目录 - Get leiningen project root directory 在没有clojure项目的情况下,“苹果酒杰克”运行clojure而不是leiningen - 'cider-jack-in' run clojure instead leiningen without a clojure project 在leiningen测试中,clojure read-line失败了 - clojure read-line fails inside leiningen test Eclipse(逆时针)-新的Clojure项目:[Exception]无法加载模板,Leiningen - Eclipse (Counterclockwise)- New Clojure Project: [Exception] Could not load template, Leiningen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM