java - Ant JUnit task NoClassDefFoundError when run in existing JVM -


i went junit ant task solution provide junit library through task's element:

<target name="test" depends="compile-tests" description="run unit tests">     <junit printsummary="true" haltonfailure="true">         <classpath refid="test.classpath" />         <test name="com.package.testclass" />     </junit> </target> 

the important classpaths used are:

<path id="test.compile.classpath">     <path refid="compile.classpath" />     <path refid="test.lib.classpath" />     <pathelement location="${build.classes.dir}" /> </path>  <path id="test.classpath">     <path refid="test.compile.classpath" />     <pathelement path="${test.classes.dir}" /> </path> 

and referenced 1 junit.jar ant maven task:

<artifact:dependencies pathid="test.lib.classpath">     <dependency groupid="junit" artifactid="junit" version="4.11" /> </artifact:dependencies> 

now, problem exception when running task:

java.lang.noclassdeffounderror: junit/framework/testlistener 

the solution adding fork="true" attribute task:

<junit printsummary="true" haltonfailure="true" fork="true"> 

my questions are:

  • why without running new jvm instance junit ant task fail include junit.jar in runtime?
  • and runtime actually? 1 executing ant script? attaching jar runtime impossible? thought standard class loading.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -