ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jérôme Lacoste <jerome.laco...@smartcardsystem.com>
Subject Bug? JUnit and classpath problems. Ant classloader?
Date Thu, 05 Jul 2001 17:29:26 GMT
Me again :)

I have some strange problems with classpath and the JUnit task.
My code use the the getResourceAsStream(String filePath) method of the Class
class.

I pass it the following String: "\test_log.properties" (note: I do that in
fact to retrieve a stream of the property files for the Log4J tool version
0.9.4). Note the '\' prefixing the name as it is a specific case of the
Class method.
(http://www.java.sun.com/j2se/1.3/docs/api/java/lang/Class.html#getResourceA
sStream(java.lang.String).


When I run my code in JBuilder everything works. If I make a batch file as
well.
But when I execute it within a JUnit Ant task, it fails.

extract of my build.xml:

<target name="test.case" if="testcase" depends="compile.tests"
	description="Runs the specified JUnit test case">
	<junit printsummary="no" haltonfailure="${bvt.haltonfailure}">
		<classpath>
			<path refid="tests.classpath" />
		</classpath>
			<formatter type="plain" usefile="${bvt.formater.usefile}" />
			<test name="${testcase}" />
	</junit>
</target>


So I guess it is a problem in Ant. I though it was a classLoader problem. I
downloaded and installed the latest nightly version of Ant but the problem
is still there.

When I run Ant with -verbose, the JUnit tasks prints correctly the classpath
I am passing, but my code (running in the same JVM) does not print the
complete classpath (i.e. ${tests.classpath} as passed by the junit task) but
prints the one created by the ant.bat script.

I tried to fork the JVM and to force to pass the correct classpath by adding
a sysproperty task before the junit one:
<!-- classpath not passed !! -->
<property name="asd" refid="tests.classpath" />
<sysproperty key="java.class.path" value="${asd}"/>

This didn't work. Forking the JVM fails because I then have to set JUnit in
my classpath, thing that I don't want.


This bug currently prevents me to use Ant to run some of my JUnit tests. Any
idea?

I was thinking of a bug in AntClassLoader but didn't investigate.

Any idea?

Jerome

Mime
View raw message