Unstable Terrain

Software development in the real world

Archive for July 2010

Ant Junit task Addendum: forkmode

leave a comment »

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"
    <classpath refid="test.class.path.with.test.classes" />
    <formatter type="xml" />
    <batchtest toDir="${test.reports}">
        <fileset dir="${test.classes.dir}">
            <include name="**/*Test*.class" />

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.


Written by Trent

July 26, 2010 at 6:44 pm

Ant Junit task : batchtest fork=true or false?

leave a comment »

Saw Erik Doernenburg’s presentation about continuous integration. In it, he mentioned that most of the time spent running junit tests is spent starting up the JVM as a result of the fork="true" setting.

It’s ‘best practice’ to fork the jvm for each test to avoid side effects of tests. However, if you happen to not suck at software development, then you will have few to none that side-effect like this (if you do, then run your junit tests in two batches).

I tried it on a few projects at work and each project experienced substantially reduced build times (up to 50% reduction). There were a few issues to do with Hibernate (batch sizes in HSQLDB) but for the most part, it just worked.

Addendum: code coverage tools may require additional changes.

Written by Trent

July 17, 2010 at 12:07 am

Posted in Software Development

Tagged with

but what if we only have crap developers

leave a comment »

Jason Gorman, quoted from this discussion:

Whenever a manager asks me “but what if we only have crap developers”, my default response is “well, in that situation, standard best practice is to fail.”

Written by Trent

July 7, 2010 at 12:01 am

Posted in Humour, Software Development

Tagged with ,