Easily partition your clojure.test
test suite across multiple JVMs.
You have a large test suite that take a long time to run - for example, your suite involves UI tests (using selenium, perhaps). Most CI tools support parallelisation within a build pipeline.
lein-test-partition
allows you to partition your test suite to run across multiple parallel nodes.
Put into the :plugins
vector of your project.clj.
When running tests using lein-test-partition
, specify the total number of partitions, and the partition number to execute.
Note: you would use this instead of your regular test runner command (e.g. lein test
)
lein-test-partition
supports two different strategies for partitioning your suite.
Tests are logically grouped together by the hash of the resolved test identifier (i.e. namespace/test-symbol). Best strategy to use to achieve a more even spread of tests across nodes.
All tests within the same namespace are grouped and executed together on the same node.
Best strategy to use if a namespace has expensive :all
fixtures.
Split your tests by namespace across 2 build nodes.
# On node 1:
$ lein test-partition part-ns :part 1 :of 2
# on node 2:
$ lein test-partition part-ns :part 2 :of 2
Split all your tests, across 4 build nodes
# On node 1:
$ lein test-partition part-tests :part 1 :of 4
# on node 2:
$ lein test-partition part-tests :part 2 :of 4
# on node 3:
$ lein test-partition part-tests :part 3 :of 4
# on node 4:
$ lein test-partition part-tests :part 4 :of 4
lein-test-partition
honours leiningen's test selectors.
# On node 1:
$ lein test-partition part-tests :part 1 :of 2 :integration
# on node 2:
$ lein test-partition part-tests :part 2 :of 2 :integration
You can use lein-test-partition
with any leiningen test runner plugin as long as it supports whitelisting tests using the :only
option.
This is possible by simply adding a command :alias
to your leiningen project.clj.
For example, to use test2junit
:
In project.clj, (perhaps in your CI profile):
...
:aliases {"test" ["test2junit"]}
...
Copyright © 2017 ICM Consulting
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.