ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorenzo Bettini <>
Subject Re: problem with junit ant task and class loading
Date Fri, 12 May 2006 13:34:41 GMT
Lorenzo Bettini wrote:
> 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
> junit/runner/
> 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" 
>                                  haltonfailure="on">
>             <formatter type="plain"/>
>             <test name="...mytest..." haltonfailure="no" 
> outfile="result">               
>             </test>
>         <classpath refid="...mypath..."/>
>         </junit>
>     </target>
> where mypath ensures that my is loaded first
> am I doing something wrong, or should I use a specific option?

I tried to debug this situation a little bit further, and by enabling 
showoutput="true" I found that the problem is a little bit different 
from the one of junit:

first of all, my classpath is ignored, and only the CLASSPATH variable 
is used together with all the paths added by ant

then, when I tried to read the contents of a class file with


that file cannot be found (this is also odd since it should be able to 
find the .class file even with the paths of CLASSPATH)

I really don't know what's going on :-(

any clue please?

thanks in advance

|  Lorenzo Bettini          ICQ# lbetto, 16080134     |
|  PhD in Computer Science                            |
|  Dip. Sistemi e Informatica, Univ. di Firenze       |
|  Florence - Italy        (GNU/Linux User # 158233)  |
|  Home Page        :    |
|         XKlaim language  |
| Deep Purple Cover Band |
|           |
|              |
|       |
|    |

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

View raw message