Alex Rivera | Logout

Ant Junit tests are running much slower via ant than via IDE - what to look at?

Asked 2008-09-23T19:11:14.303
9

I am running my junit tests via ant and they are running substantially slower than via the IDE. My ant call is:

    <junit fork="yes" forkmode="once" printsummary="off">
        <classpath refid="test.classpath"/>
        <formatter type="brief" usefile="false"/>
        <batchtest todir="${test.results.dir}/xml">
            <formatter type="xml"/>
            <fileset dir="src" includes="**/*Test.java" />
        </batchtest>
    </junit>

The same test that runs in near instantaneously in my IDE (0.067s) takes 4.632s when run through Ant. In the past, I've been able to speed up test problems like this by using the junit fork parameter but this doesn't seem to be helping in this case. What properties or parameters can I look at to speed up these tests?

More info:

I am using the reported time from the IDE vs. the time that the junit task outputs. This is not the sum total time reported at the end of the ant run.

So, bizarrely, this problem has resolved itself. What could have caused this problem? The system runs on a local disk so that is not the problem.

Edit
Report

2 Answers

4

I'm guessing it's because your antscript is outputing results to XML files, whereas the IDE is keeping those in memory. It takes longer to write a file than to not write a file.

todir="${test.results.dir}/xml"

That's the part of the <batchtest> call that tells it to stick the results into that directory. It looks like leaving it off just tells it to stick the results in the "current directory", whatever that is. At first glance I didn't see anything to turn it all the way off.

answered 2008-12-18T13:50:53.177
1

Difficult to tell with that information. First thing I would do is look at the test results and determine if all the individual tests are running uniformly slower or if it can be narrowed down to a certain subset of test cases.

(The zero'th thing I would do is make sure that my ant task is using the same JVM as Eclipse and that the classpath dependencies and imported JARs are really and truly identical)

answered 2008-09-23T19:18:05.863

Your Answer