Wednesday, August 3, 2011

Ant, Junit and the forked JVM

I have a classpath defined as:


<path id="classpath.test">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement location="/path/to/user_projects/domains/acme_osb/config/osb/"/>
</path>


I can trace it this way:

<echo message="${toString:classpath.test}"/>


and I use it in a junit task

<junit printsummary="true">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false"/>
<test name="com.acme.gu.ft.GUFT" outfile="junitout/GUFT">
<formatter type="xml"/>
</test>
</junit>



The alarming thing is that the Unit test is run NOT with the classpath I specify (classpath.test), but with the classpath being used to run ant.

I can trace it with System.getProperty("java.class.path")


The only way to run the Unit Test with the new Classpath is by specifying fork="on"

<junit printsummary="true" fork="on">


one hour wasted for this....

No comments: