Thursday, May 24, 2007

Problem: cannot find symbol constructor TestCase()

I was struggling with a strange problem for a few days. Now I found partially the reason of the problem. A very simple test class didn't compile in my project:


import junit.framework.TestCase;

public class MyTest extends TestCase {
public void testMe() {
assertTrue(true);
}
}


The IDE (intellij) didn't compile it by saying:


cannot find symbol constructor TestCase()


This was very strange at first. After lots of trials and errors I found out that the reason for this compile error was that there was a conflict between the dependencies. Specifically the conflict was between junit.jar and repast.jar.

When repast.jar has a higher order than junit.jar then the test class doesn't compile. I didn't understand exactly why it occurred but it seems that it has a relation to the classpath declaration in the manifest.mf file of repast.jar, which states:


Class-Path: lib/junit.jar lib/log4j-1.2.8.jar lib/openmap.jar lib/plot.jar


Moreover repast's own junit has a smaller version than 3.8.

No comments: