Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Clojure and Java simultaneously

I'm developing a library that contains both Clojure and Java code, using Eclipse + Maven to manage the project.

I have a good set of JUnit tests that cover the Java portion of the code base, and also have a separate set of Clojure tests written using the standard clojure.test toolset.

Ideally I'd like to be able to run all tests simultaneously as part of the build process. I have the clojure-maven-plugin installed, but it still only seems to run the JUnit tests and ignores the Clojure ones.

How can I achieve this?

like image 691
mikera Avatar asked Dec 30 '25 08:12

mikera


1 Answers

OK, I figured out how to do this myself with a little help from the information in the answers to this question on testing Clojure with Maven.

The trick was to add the following section to the pom.xml:

  <build>
    <plugins>
        <plugin>
            <groupId>com.theoryinpractise</groupId>
            <artifactId>clojure-maven-plugin</artifactId>
            <version>1.3.8</version>

            <executions>
                <execution>
                    <id>test-clojure</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

    <testResources>
      <testResource>
        <directory>src/test/clojure</directory>
      </testResource>
    </testResources>
  </build>

This has the effect of running the Clojure test cases as part of the standard Maven test goal.

EDIT

As of 2012, a good alternative is to use cljunit to run the Clojure tests as part of a regular JUnit test suite.

like image 159
mikera Avatar answered Jan 01 '26 22:01

mikera