Ant unit test forking behaviour

There is a long-standing issue with the way that ant’s JUnit task runs tests. The default behaviour is to fork off a new JVM for each test - which is *very* slow, particularly if you are doing something like GWT Unit Tests.

In this case, the whole GWT environment bootstrap (about 20 seconds on our cruise box) happens once per test. Ouch.Fortunately there is a solution, in ant 1.6.2 and above - use the forkMode attribute :

<junit fork="true" forkMode="once" ...

See the junit tag documentation for more details :

http://ant.apache.org/manual/OptionalTasks/junit.html

2 Responses to “Ant unit test forking behaviour”

  1. Sidu Says:

    Chris, using a TestSuite can speed up GWT Tests a fair amount as the environment is loaded just once for each suite - though this probably is the same as what the ant forkMode achieves anyway :)
    See http://diningtablecoder.blogspot.com/2007/03/gwt-unit-tests-running-slowly-use.html

  2. Usefascaria Says:

    Hello,
    I am, Paul
    some crazy threads
    check out my page:

    http://WXjXvmNfF.spaces.live.com/

Leave a Reply