Horace
Horace

Reputation: 1208

clojure maven plugin: clojure tests succeed when using mvn clojure:test but NOT during test phase when using mvn install

I am using the clojure maven plugin to build a project. The projects contains a test, let us say mytest.clj, that has a content like the following:

(def ^:dynamic *server*
  (create-server "tcp://bla.bla:9999"))

(deftest blabla1...)
(deftest blabla2...)

If I run mvn clojure:test , the build runs successfully.

But If I run mvn install then when the test phase is reached, the server declared in mytest.clj is started. After that start, nothing more happens: the clojure test script seems to be frozen and building of the project cannot be continued (without any error message): Maven just hangs. Although, as already said, mvn clojure:test runs successfully for the same project.

Does somebody know how to solve this problem?

Any help will be appreciated. Thx in advance Regards

Horace

P.S: I can use the standard mvn install to compile and test the clojure sources because my project's packaging is configured as a 'clojure' one in pom.xml. The consequence of it, is that the clojure maven plugin then automatically binds itself to the maven phases compile, test and test-compile.

Upvotes: 1

Views: 184

Answers (1)

Daniel E. Renfer
Daniel E. Renfer

Reputation: 13

The problem is you are starting a server when the tests are run, but you are not shutting down that server when everything is finished.

You'll want to use fixtures to make sure you're killing any threads/agents/servers you start in the test.

See Clojure: How To use-fixtures in Testing

Upvotes: 1

Related Questions