Ant Junit task Addendum: forkmode
I mentioned previously about using the ant junit task with fork=false.
However, some tools such as EMMA insert shutdown hooks, so require forking. In addition, classloader issues may require you to fork to save your own sanity.
Turns out there’s a more robust solution.
<junit haltonfailure="yes" printsummary="yes" fork="true" forkmode="once"> <classpath refid="test.class.path.with.test.classes" /> <formatter type="xml" /> <batchtest toDir="${test.reports}"> <fileset dir="${test.classes.dir}"> <include name="**/*Test*.class" /> </fileset> </batchtest> </junit>
A new JVM will be forked, but all tests will be run inside that single forked JVM, increasing the speed of your tests substantially. If you have some tests that have side-effects, you can put them into a separate batch and change the forkmode to ‘perBatch‘, effectively isolating them while retaining the speed of the rest of your tests.
So, try it and see how much faster your build goes.
Advertisements
Leave a Reply