Is there a custom load order for classes with ant junit task?

in our web application project, we include some jar files. To fix some issues with one of the classes in the jar file, we changed the implementation of that class in the original patch folder.

Since there is a certain order of loading classes in tomcat (WEB-INF / classes before WEB-INF / lib), the patched version of the class is loaded by tomcat and not the original one in the jar file. So, once we deploy our application, everything works as expected.

Now we want to run junit tests from ant against this fixed class. Therefore, we set up the classpath to store both the original and the patched class file. But there seems to be no way to tell the ant junit task to load the patched class first and not the non-empty version from the jar file.

Is there a way to get around the problem? Is there a way to determine the order in which the classes are loaded using the ant junit task? Is there another way to test our revised ant class?

+2


source to share


1 answer


I think the ant classpath works the same as the standard Java classpath. Class searches are performed in the order in which the paths are declared and the class is loaded from the first path where it is found.

The classpath element for your junit task should look something like this:



<classpath>
  <pathelement location="${patched.class.folder}"/>
  <pathelement location="${original.class.jar}"/>
</classpath>

      

+1


source







All Articles