Getting started

Jar dependencies

The following jars has to be in the classpath:

  • velocity-dep-1.4.jar
  • velocity-1.4.jar
  • ant-junitmm-1.0.0.jar

ANT Build file parts

  ...snip...
  
  <taskdef name="javadoc-junit"
           classname="org.woopi.ant.taskdefs.junit.JUnitTask">
      <classpath>
          <path refid="class.path"/>
      </classpath>
  </taskdef>
  <taskdef name="javadoc-junitreport"
           classname="org.woopi.ant.taskdefs.junit.JunitVelocityReportTask">
      <classpath>
          <path refid="class.path"/>
      </classpath>
  </taskdef>

  ...snip...

  <target name="javadoc4junit" depends="init">
    <javadoc sourcepath="${dir.src}"
        classpathref="class.path"
        docletpathref="class.path"
        packagenames="org.*"
        author="true"
        private="true"
        version="true"
        >
     <doclet name="org.woopi.ant.taskdefs.junit.JavadocExtractor">
        <param name="-J-DJavadocExtractor.destDir=target/classes"/> 
     </doclet>
    </javadoc>
  </target>
  
  <target name="test" depends="compile,init,javadoc4junit">
    <delete dir="${dir.test-results}"/>
    <mkdir  dir="${dir.test-results}"/>
    <javadoc-junit printsummary="yes" 
              showoutput="yes"
              haltonfailure="no"
              >
      <classpath refid="class.path"/>

      <formatter type="javadoc-xml"/>

      <batchtest fork="yes" todir="${dir.test-results}">
        <fileset dir="${dir.test-src}">
          <include name="**/*Test*.java"/>
        </fileset>
      </batchtest>
    </javadoc-junit>
  </target>

  <target name="testReport" depends="test" >
    <delete dir="${dir.test-reports}"/>
    <mkdir  dir="${dir.test-reports}"/>
    <javadoc-junitreport todir="${dir.test-reports}">
      <fileset dir="${dir.test-results}">
        <include name="TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${dir.test-reports}/html"/>
    </javadoc-junitreport>
  </target>
  

Example TestCase adapted for javadoc-junit

  ...snip...
import org.woopi.ant.taskdefs.junit.JavadocExtractor;
import org.woopi.ant.taskdefs.junit.Documented;

public class TestExample extends TestCase implements Documented {
  

    public String getMethodDoc(String methodName){
      String result = JavadocExtractor.getMethodDocByObject(this, methodName);
      return result;
    }
    
    public String getClassDoc(String className){return "ClassDoc";}
    public String getFieldDoc(String fieldName){return "FieldDoc";}
  
  
    public TestExample( String testName )
    {
        super( testName );
    }
    
  ...snip...