• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol constructor TestCase()  RSS feed

 
albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code has this error when compiled in junit 3.8.2 & jdk 6 & Eclipse 3.3.2:
cannot find symbol
[javac] symbol : constructor TestCase()
[javac] location: class junit.framework.TestCase
[javac] public class TestProIndexBean extends TestCase {
[javac] ^
[javac] 1 error




I add the src.jar to the source path to project in Eclipse by the menu
Project->Properties->Source->Link Source

I add the junit.jar to the build path to project in Eclipse by the menu
Project->Properties->Libraries->Add External JARs

I select the build.xml by right clicking to execute "Run As"->"Ant build" menu.
build.xml is as follows:
<!-- ... -->
<target name="compile" depends="copyExtras" description="Compile the NEDD Classes">
<!-- Compile the Java classes -->
<echo message="Compiling..."/>
<mkdir dir="${classes}"/>
<exec executable="java">
<arg line="-version"/>
</exec>
<javac srcdir="${src}" destdir="${classes}" classpathref="classpath" debug="true" fork="true" memoryMaximumSize="512m"/>
</target>
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every class needs a constructor. If you don't define one, the compiler will try to define one for you. One scenario when the compiler cannot do this is when your super class has a constructor with arguments. In this case, you must define your own constructor and this is what the error message is trying to tell you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!