Maven Clojure插件没有运行测试

时间:2015-04-13 00:17:39

标签: java maven junit clojure maven-3

我正在尝试使用Java,Scala和Clojure创建一个包含maven的简单项目。我为每种语言都有简单的测试类,但是当运行mvn test时,clojure测试没有执行。

我使用clojure-maven-plugin来编译和测试clojure代码,当运行mvn目标mvn clojure:test-with-junit时,它按预期运行,我得到以下输出:

[INFO] --- clojure-maven-plugin:1.3.20:test-with-junit (default-cli) @ functional-programming-patterns ---
Tests run: 2, Assertions: 1, Failures: 1, Errors: 0
There are test failures.

但是,当我刚刚运行mvn test时,我只能运行Java和Scala测试:

Running main.HelloWorldJavaTest
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.06 sec <<< FAILURE!
Running main.HelloWorldScalaTest
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.312 sec <<< FAILURE!

Results :

Failed tests:   fail(main.HelloWorldJavaTest): expected:<1> but was:<2>

Tests in error:
  fail(main.HelloWorldScalaTest): 1 did not equal 2

Tests run: 4, Failures: 1, Errors: 1, Skipped: 0

我的plugin配置如下:

<plugin>
    <groupId>com.theoryinpractise</groupId>
    <artifactId>clojure-maven-plugin</artifactId>
    <version>1.3.20</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <id>clojure-compile</id>
            <phase>compile</phase>
            <goals>
                <goal>add-source</goal>
                <goal>compile</goal>
            </goals>
            <configuration>
                <sourceDirectories>
                    <sourceDirectory>src/main/clojure</sourceDirectory>
                </sourceDirectories>
            </configuration>
        </execution>
        <execution>
            <id>clojure-test</id>
            <phase>test</phase>
            <goals>
                <goal>test-with-junit</goal>
            </goals>
            <configuration>
                <testSourceDirectories>
                    <testSourceDirectory>src/test/clojure</testSourceDirectory>
                </testSourceDirectories>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <sourceDirectories>
            <sourceDirectory>src/main/clojure</sourceDirectory>
        </sourceDirectories>
        <testSourceDirectories>
            <testSourceDirectory>src/test/clojure</testSourceDirectory>
        </testSourceDirectories>
    </configuration>
</plugin>

我只是想知道插件中是否有某些东西导致我的Clojure测试在我的Scala和Java运行时都没有运行。

更新

我一直在玩这个,看起来它没有正确地绑定到mvn test阶段。当我切换相位时插件从test连接到process-test-resources,测试运行就好了。但是,由于测试失败,Java和Scala都没有运行。

1 个答案:

答案 0 :(得分:0)

经过一些试验和错误后,我发现如果Java或Scala测试中出现测试失败,Clojure插件将无法运行。但是,如果所有Java和Scala测试都通过了,它将按预期运行Clojure测试。

我已使用插件记录an issue