ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Starkie" <>
Subject RE: fork=yes VS. BUILD SUCCESSFUL
Date Mon, 05 Nov 2001 17:32:22 GMT
The way I get around this problem is to not use the junit optional task. Instead I just use
the built-in java task to call the junit test class directly.  If you set fork=yes and failonerror=yes
a failed assertion will result in BUILD FAILED and so will system.exit(-1).  System.exit(0)
There is another advantage in using java instead of junit.  java will always call Main() in
the junit test class allowing me the option of doing some preprocessing before or after I
run the tests; for instance I needed to call sleep() after running the tests to allow them
ample time to complete.  The junit optional task uses reflection to get the testCaseName of
the tests you want to run just like you would in Main() only it does this under the hood without
ever calling Main() in your test suite.  It could be that the optional junit task is returning
system.exit(0) somewhere where it shouldn't and confusing ant but this is just a guess.  
Using java instead of junit should fail properly when an assertion is failed in a forked process.

>Reply-To: "Ant Users List" <>
>Date: Mon, 5 Nov 2001 08:37:32 -0800
> "Michael Starkie" <> fork=yes VS.
>we have a dillema using Ant in our development environment.  The problem is with the junit
optional task.
>the problem is that when we set fork=true Ant concludes with BUILD_SUCCESSFUL even though
the unit tests fail. I assume this is because it's impossible for ant to get the return code
of another process.
>BUT when we set fork=false the unit tests fail with linkeage errors due to the fact that
both the JVM and ant load the same JAXP classes from the classpath.
>We must use fork=true to avoid the linkage errors so how can we detect that the tests
really failed automatically despite the fact that Ant returns BUILD_SUCCESSFUL.
>--== Sent via ==--
>To unsubscribe, e-mail:   <>
>For additional commands, e-mail: <>

--== Sent via ==--

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message