ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorenzo Bettini <>
Subject problem with junit ant task and class loading
Date Fri, 12 May 2006 12:23:28 GMT
Hi there

I've just started using ant and junit task

I have a test suite that I usually run from within eclipse and always worked

one of these tests uses a custom class loader

now I see that if I try to run the test with custom class loader from
console (i.e., using junit.textui.TestRunner) everything's fine and all
the 3 test methods of the test case run successfully...  if I use a
graphical interface (i.e., junit.swingui.TestRunner) I get a
ClassCastException that is due to the fact that some classes are loaded
with different class loaders...

now I found the way to solve this problem when running junit directly: 
as illustrated in the junit FAQ I put the


in my CLASSPATH and added lines in this file so that my classes are 
loaded through the system class loader.

However, the problem still exists if I run the ant task.  I think the 
problem is the same in that the same test never returns (and I see no 
output on the screen).

I'm using this target

<target name="junit" depends="tests" description="--> run junit tests">
     	<junit printsummary="withOutAndErr" haltonerror="on" 
     		<formatter type="plain"/>
     		<test name="...mytest..." haltonfailure="no" outfile="result">    			
		<classpath refid="...mypath..."/>

where mypath ensures that my is loaded first

am I doing something wrong, or should I use a specific option?

thanks in advance

|  Lorenzo Bettini          ICQ# lbetto, 16080134     |
|  Home Page        :    |
| Deep Purple Cover Band |
|           |
|              |
|       |
|    |

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

View raw message