I get really strange ClassNotFoundExceptions with JUnit 3.7#

Does your class work fine if you run the test cases using the TextRunner? If yes, then the following explanation is probably correct: The graphical test runners use a different class loader than the text version. This class loader uses a special list, junit/runner/excluded.properties to define which classes are never reloaded, and it typically contains classes such as sun.*, javax.*, com.sun.*, etc. The class loader does not load files from a jar-file, and since most of external libraries are distributed as such, you need to either unpack your external jar, or tell the JUnit class loader which classes should never be reloaded. The latter is probably more sensible, so you won't have unpacked jars cluttering your directory structure.

You need to unpack the junit.jar file, and edit the excluded.properties file to add packages like org.apache.* and org.xml.*. Then repack the junit.jar file and use that. Check http://www.shinetech.net/junit/doc/faq/faq.htm for more info. Here's an example excluded.properties file:

#
# The list of excluded package paths for the TestCaseClassLoader
#
excluded.0=sun.*
excluded.1=com.sun.*
excluded.2=org.omg.*
excluded.3=javax.*
excluded.4=sunw.*
excluded.5=java.*
excluded.6=junit.*
excluded.7=oracle.*
excluded.8=org.apache.*   

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 24-Jul-2001 19:51 by UnknownAuthor