testing Clojure in Maven

前端 未结 4 1365
傲寒
傲寒 2021-01-04 23:24

I am new at Maven and even newer at Clojure. As an exercise to learn the language, I am writing a spider solitaire player program. I also plan on writing a similar program i

相关标签:
4条回答
  • 2021-01-04 23:56

    You probably want to point testSourceDirectory at src/test/clojure:

    <sourceDirectory>src/main/clojure</sourceDirectory>
    <testSourceDirectory>src/test/clojure</testSourceDirectory>
    
    0 讨论(0)
  • 2021-01-05 00:04

    You can look to this example of pom.xml with clojure-maven-plugin & tests. By default, clojure-maven-plugin should generate test-runner automatically, as described in documentation.

    And it's better to use latest version of clojure-maven-plugin - 1.3.2, in which there are several bugs were fixed

    0 讨论(0)
  • 2021-01-05 00:14

    I would not expect the surefire plugin to run something else than Java tests so, with your current setup, there is indeed "No tests to run". I suggest to use the clojure-maven-plugin here. Also check Why using Maven for Clojure builds is a no-brainer.

    0 讨论(0)
  • 2021-01-05 00:21

    The key bit you're missing from your pom.xml (just cribbing from the clojure-contrib pom.xml) is an execution under the clojure-maven-plugin:

    <plugin>
        <groupId>com.theoryinpractise</groupId>
        <artifactId>clojure-maven-plugin</artifactId>
        <version>1.3.2</version>
        <!-- Current Config -->
        <executions>
            <!-- ... -->
            <execution>
                <id>test-clojure</id>
                <phase>test</phase>
                <goals>
                    <goal>test</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    

    It may also be necessary to add something like this under <build/>:

    <testResources>
        <testResource>
          <directory>src/test/clojure</directory>
        </testResource>
    </testResources>
    
    0 讨论(0)
提交回复
热议问题