An Ant task for running JUnit tests in parallel
Parallel JUnit is an Ant task for running JUnit tests in parallel. We wrote this task while trying to harness the power of modern developer workstations to decrease our pre-commit build time. As of the initial release it supports a subset of the features of the standard Ant JUnit task which was most useful to us! However, we believe that the current state of the task will allow it to work (almost) as a drop-in replacement for the standard JUnit task for most people.
<project name="myproj" xmlns:pju="antlib:com.lmax.ant.paralleljunit">
<taskdef resource="com/lmax/ant/paralleljunit/antlib.xml"
uri="antlib:com.lmax.ant.paralleljunit">
<classpath>...</classpath>
</taskdef>
<pju:parallel-junit printsummary="on" threads="4">
<jvmarg .../>
<sysproperty .../>
<classpath>
...
</classpath>
<formatter type="xml"/>
<batchtest todir="build/test-reports/xml">
...
</batchtest>
</pju:parallel-junit>
</project>
The most interesting thing about this is the threads attribute. Possible values for this are:
Value | Number of workers used |
---|---|
not specified | Runtime.availableProcessors() |
n% | n% of Runtime.availableProcessors() |
-n | Runtime.availableProcessors() - n |
n | n |
If you specify shuffle="yes", the task will shuffle the list of tests before starting any of the worker threads. This setting defaults to "no", but can be useful for flushing out test dependencies, or for when you have some longer-than-you'd-like tests which happen to otherwise end up at the end of the run giving you a long tail.
The original authors were Dalibor Novak (@BorePlusPlus) and Danny Yates (@codeaholics)
We welcome contributions to Parallel JUnit - especially if they extend the task to cover some of the missing functionality of the JUnit task. Please fork us on GitHub and send us a pull request.
If you've found a bug, please raise an issue in the issue tracker.