java - error: package org.junit does not exist -
i keep getting these errors when trying run ant file.
[javac] compiling 8 source files c:\users\faradayscage\git\mancala\build [javac] c:\users\faradayscage\git\mancala\src\tests\boarddatatest.java:1: error: package org.junit not exist [javac] import static org.junit.assert.assertequals; [javac] ^ [javac] c:\users\faradayscage\git\mancala\src\tests\boarddatatest.java:1: error: static import classes , interfaces [javac] import static org.junit.assert.assertequals; [javac] ^ [javac] c:\users\faradayscage\git\mancala\src\tests\boarddatatest.java:2: error: package org.junit not exist [javac] import org.junit.test; [javac] ^ [javac] c:\users\faradayscage\git\mancala\src\tests\boarddatatest.java:8: error: cannot find symbol [javac] @test
this ant build file
<project name="mancala" default="fullbuild" basedir="."> <description> build file mancala program. handles compilation , distribution. include automated testing , generation of documentation. </description> <!-- set global properties build --> <property name="src" location="src" /> <property name="build" location="build" /> <property name="build.test" location="build/tests" /> <property name="dist" location="dist" /> <property name="test" location="src/tests" /> <property name="docs" location="docs" /> <property name="test.report" location="testreport" /> <!-- define classpath includes junit.jar--> <!-- , classes after compiling--> <path id="junit.class.path"> <pathelement location="lib/junit-4.11.jar" /> <pathelement location="lib/hamcrest-core-1.3.jar" /> <pathelement location="${build}" /> </path> <target name="init"> <!-- create time stamp --> <tstamp /> <!-- create build directory structure used compile --> <mkdir dir="${build}" /> <!-- create testreport directory used junit --> <mkdir dir="${test.report}" /> <!-- create build.test directory used compile & junit --> <mkdir dir="${build.test}" /> </target> <target name="compile" depends="init" description="compile source"> <!-- compile java code ${src} ${build} --> <javac srcdir="${src}" destdir="${build}" /> <javac srcdir="${test}" destdir="${build.test}" /> </target> <!-- run junit tests --> <!-- output xml, plain--> <target name="junit" depends="compile"> <junit printsummary="on" fork="true" haltonfailure="yes"> <classpath> <classpath refid="junit.class.path" /> <pathelement location="${build.test}" /> <formatter type="plain" /> <batchtest todir="${test.report}"> <fileset dir="${test}"> <include name="**/*test*.java" /> </fileset> </batchtest> </classpath> </junit> </target> <target name="doc" description="generate documentation"> <mkdir dir="${docs}" /> <javadoc sourcepath="${src}" destdir="${docs}"> <fileset dir="${src}" /> </javadoc> </target> <target name="dist" depends="compile" description="generate distribution"> <!-- create distribution directory --> <mkdir dir="${dist}/lib" /> <!-- put in ${build} mancala-${dstamp}.jar file --> <jar jarfile="${dist}/lib/mancala-${dstamp}.jar" basedir="${build}" /> </target> <!-- runs compiled application --> <target name="run" depends="compile"> <java classname="mancalaapp"> <classpath> <pathelement location="${build}" /> </classpath> </java> </target> <!--add unit tests build once implemented--> <target name="fullbuild" depends="dist, doc, junit" description="create application, docs, , tests"> </target> <target name="clean" description="clean up"> <!-- delete ${build} , ${dist} directory trees --> <delete dir="${build}" /> <delete dir="${dist}" /> <delete dir="${docs}" /> <delete dir="${build.test}" /> <delete dir="${test.report}" /> </target> </project>
i know somehow not including junit.jar build, should being included because of in path id, , @ wits end wrong.
thank in advance
the <javac>
task creates tests needs classpath:
<javac srcdir="${test}" destdir="${build.test}" classpathref="junit.class.path" />
by way, following doesn't right:
<junit printsummary="on" fork="true" haltonfailure="yes"> <classpath> <classpath refid="junit.class.path" /> <pathelement location="${build.test}" /> <formatter type="plain" /> <batchtest todir="${test.report}"> <fileset dir="${test}"> <include name="**/*test*.java" /> </fileset> </batchtest> </classpath> </junit>
the <formatter>
, <batchtest>
elements shouldn't nested under <classpath>
. should directly under <junit>
. should more like:
<junit printsummary="on" fork="true" haltonfailure="yes"> <classpath> <classpath refid="junit.class.path" /> <pathelement location="${build.test}" /> </classpath> <formatter type="plain" /> <batchtest todir="${test.report}"> <fileset dir="${test}"> <include name="**/*test*.java" /> </fileset> </batchtest> </junit>
Comments
Post a Comment